Discover: how many numbers does a network really need?
A small network that classifies handwritten digits (the MNIST dataset), with layers of 784, 200, 200 and 10 neurons, has 199,210 parameters. Normal training adjusts every one of them. In 2018 four researchers at Uber AI Labs asked an odd question: what if we only let the network move in a few directions? They froze a random starting point and a random matrix, and trained a much shorter vector instead:
Spotted in the wild
Read it aloud: “theta D equals theta-nought D plus P times theta d.” The bracketed superscripts are labels, not powers (Mathematics for ML, Chamber 1): they say which space each vector lives in. is the full list of parameters, is a random starting point, is a random matrix with rows and columns, and is a short vector of just numbers. Only is trained.
With , the digit classifier already reached 90% of the accuracy of the normally trained network. Out of 199,210 directions, 750 random ones were enough. That raises questions this chamber answers. Which settings of the weights can such a network actually reach? What exactly is a “direction”, and when do 750 of them really give 750 different ones? And why 750, not 10 or 100,000? The words for these ideas are span, independence and dimension.
Take a guess before reading on. In , the matrix has rows and columns, and only is trained. For the MNIST network, and . How many numbers does training adjust?
Learn: the span of a set of vectors
In Chamber 1 you built linear combinations: scale some vectors, then add them up. The span asks the natural next question: what are all the vectors you can build that way?
The set-builder braces are the ones from Mathematics for ML, Chamber 2. The coefficients are free: positive, negative, zero, fractions, anything real. Now picture the geometry:
- One non-zero vector : its span is every multiple , a line through the origin.
- Two vectors in that don't lie along the same line: their span is the whole plane.
- Two such vectors in : a plane through the origin, a flat sheet inside space.
- The zero vector alone: its span is , the single point at the origin.
- “the span of v one to v k”Every linear combination with real coefficients: all the points these vectors can reach.
- “the zero subspace”The set whose only element is the zero vector. The smallest subspace there is, and the span of alone.
- “a dependency relation”A combination that lands on . If one exists with some , the vectors are dependent; if only all-zero coefficients work, they are independent.
- “the determinant of u and v”For two vectors in the plane, : the signed area of the parallelogram they span. Zero exactly when they are dependent. Chamber 5 builds determinants in general.
| Symbol | Say it | Meaning | LaTeX |
|---|---|---|---|
| “the span of v one to v k” | Every linear combination with real coefficients: all the points these vectors can reach. | ||
| “the zero subspace” | The set whose only element is the zero vector. The smallest subspace there is, and the span of alone. | ||
| “a dependency relation” | A combination that lands on . If one exists with some , the vectors are dependent; if only all-zero coefficients work, they are independent. | ||
| “the determinant of u and v” | For two vectors in the plane, : the signed area of the parallelogram they span. Zero exactly when they are dependent. Chamber 5 builds determinants in general. |
Is a given vector in the span? That's a question about finding coefficients. Is in the span of and ? We need numbers with
Subtracting the first equation from the second gives , and then . Check: . So yes, it's in the span.
Now try with and in . Any combination is . The first two entries force and , and then the third entry is , not . No coefficients work, so is not in the span. The span of and is a plane (the points whose third entry is the sum of the first two), and floats just above it.
Which vector lies in ?
Learn: subspaces, and a first proof
Lines and planes through the origin share a property: you can't escape them by adding or scaling. Add two vectors on a line through the origin and you land on the same line. Stretch one and you stay on it. Sets with that property get a name.
In the subspaces are exactly , the lines through the origin, and the whole plane. The line is not a subspace, because it misses the origin. Neither is a disc around the origin: scale any point by 100 and you leave it.
Here's a theorem with a complete proof. It says a span is always one of these well-behaved sets.
Claim. For any vectors in , the set is a subspace.
Proof. We check the three conditions in turn.
Zero. Choose every coefficient to be : . So .
Addition. (You met this step in Chamber 1's proof puzzle: combinations of combinations are combinations.) Take any . By the definition of span, there are numbers and with and . (Two different lists of letters, because and may need different coefficients.) Adding, and grouping the terms for each ,
which is again a linear combination of the . So .
Scaling. For as above and any , we have , another linear combination. So .
All three conditions hold, so is a subspace.
Notice the rhythm of the argument: unpack the definition (“in the span” means “equals some combination”), do a line of algebra, then repack the definition. Most proofs in linear algebra move to this beat.
Learn: linear independence
Some lists of vectors carry dead weight. In the list , , the second vector is just , so including it reaches nothing new: , a line. Linear independence is the precise way to say “no dead weight”.
Why does this capture dead weight? Suppose with some coefficient non-zero; renumber so that it's . Divide by and rearrange:
So is a combination of the others, and dropping it doesn't shrink the span. Dependent means redundant; independent means every vector pulls its weight. For and the witness is .
Two consequences are worth remembering. Any list that contains is dependent, because uses a non-zero coefficient. And two vectors are dependent exactly when one is a multiple of the other, which means they lie on a common line through the origin.
A test for two vectors in the plane
In Chamber 1 you solved by elimination and met the number . Chamber 1 left you a claim to check: exactly when the two vectors share a line. Now we can prove it, and turn into a complete test for independence. Write and , set the target to , and look for coefficients with . That's one equation per entry:
Eliminate exactly as in Chamber 1. Multiply (1) by and (2) by , then subtract the second result from the first. The terms cancel, leaving
To eliminate instead, multiply (1) by and (2) by , then subtract the first result from the second:
The same number appears in both. Chamber 1 promised that it would come back as the determinant, and here it is, a little early, written for the pair as
If , divide both equations by it: and . The only combination giving is the trivial one, so the vectors are independent.
If , they are dependent, and we can write down a witness. Take and . Equation (1) becomes , and equation (2) becomes . Both hold. That witness is non-zero unless ; in that case both vectors lie on the -axis and , works instead (or , if both vectors are ).
So, for two vectors in the plane:
For example, and give : dependent, and indeed . But and give : independent.
Geometrically, is the signed area of the parallelogram with sides and . A flat parallelogram has zero area, and that's exactly when the vectors are dependent. Chamber 5 builds determinants for matrices of any size. For now, it's your independence meter.
Which pair of vectors is linearly dependent?
Now play with it. Drag the two vectors and watch the span. The lab asks you to hit a target with a combination , and then to make the span collapse.
Interactive lab
Span explorer
u and v are independent, so their span is the whole plane. Slide a and b to land on the target.
Independence meterdet[u v] = 3
Independent: the parallelogram on u and v has area |det|.
a·u + b·v
(3, 3)
target t
(1, 5)
- Land a·u + b·v on the target (within 0.2).
- Make the span collapse to a line, with u and v both non-zero.
Learn: bases and coordinates
Span tells you how much you can reach, and independence tells you there's no waste. Put them together and you get the most useful idea in the chamber.
The standard basis , from Chamber 1 is a basis of , but far from the only one. and form another: , so they are independent, and two independent vectors in the plane span all of it.
The pay-off of a basis is coordinates. Every in can be written as (because the basis spans), and in only one way (because it's independent). Chamber 1 proved this for the standard basis; you'll assemble the proof for any basis in Your turn. Those unique coefficients are the coordinates of in the basis , written
and read “the coordinates of x in basis B”.
Worked example: find the coordinates of in . We need , that is, and . Adding the equations gives , so and :
In the standard basis the same vector has coordinates . One arrow, two descriptions. The vector didn't move; only the ruler changed.
- “the basis B”An ordered list of vectors that is linearly independent and spans the space. Bases usually get calligraphic letters.
- “the coordinates of x in basis B”The unique coefficients with . Same arrow, different ruler.
- “the dimension of U”The number of vectors in any basis of the subspace . All bases of have the same size.
- “d int, the intrinsic dimension”From Li et al. (2018): the number of directions that actually matter for solving a problem, , where is the dimension of the solution set.
| Symbol | Say it | Meaning | LaTeX |
|---|---|---|---|
| “the basis B” | An ordered list of vectors that is linearly independent and spans the space. Bases usually get calligraphic letters. | ||
| “the coordinates of x in basis B” | The unique coefficients with . Same arrow, different ruler. | ||
| “the dimension of U” | The number of vectors in any basis of the subspace . All bases of have the same size. | ||
| “d int, the intrinsic dimension” | From Li et al. (2018): the number of directions that actually matter for solving a problem, , where is the dimension of the solution set. |
Every spanning list contains a basis. Walk through the list in order, and throw away each vector that's already in the span of the vectors you've kept. What survives still spans the same set, since you only threw away redundant vectors. And it's independent: if some combination of the survivors gave with a non-zero coefficient, the last survivor with a non-zero coefficient would be a combination of earlier survivors, and you would have thrown it away. Problem 3 below asks you to run this sifting algorithm on a table of features.
Learn: dimension
A plane through the origin has infinitely many bases, but every one of them has exactly two vectors. That's no accident.
The proof that all bases have the same size takes a page of careful bookkeeping (it's in Axler's Chapter 2, listed below), so we'll take it on trust here. What it buys us is a single number that measures how big a subspace is:
| Subspace | A basis | Dimension |
|---|---|---|
| the empty list | ||
| a line through | any non-zero vector on it | |
| a plane through in | any two independent vectors in it | |
Three rules of thumb follow, and they're worth more than their size. In , more than vectors are always dependent: three vectors in the plane always carry dead weight. Fewer than vectors never span: two vectors can't fill space. And , with equality exactly when the vectors are independent.
A worked example: the plane . You can choose and freely, and then is forced. So every vector in has the form
The two vectors on the right span , and they're independent (look at their first two entries). So they form a basis and . One linear equation in removed one dimension. Keep that pattern in mind: it's exactly how Li et al. count.
What is the dimension of ?
Back to the paper: intrinsic dimension
Before touching a network, Li et al. warm up with a toy problem that you can now solve in your head. Take parameters, split them into 10 groups of 100, and require that the first group sums to 1, the second to 2, and so on up to 10. Each requirement is one linear equation, and just like above, each removes one dimension. The solutions form a flat set of dimension . The paper defines the intrinsic dimension as what's left over:
Spotted in the wild
Here . Out of a thousand numbers, only ten things need to be got right. Now train in a random -dimensional subspace, as in Eq. (2). The columns of are random, so they are independent (with probability 1) and the subspace really has dimension . With the subspace (almost surely) misses the solution set; with it meets it. So sweep upwards and watch for the first success: it happens at , and it measures .
For real networks nobody can count the equations, so the authors sweep and call a subspace successful when it reaches 90% of the performance of normal training. They call the first such the intrinsic dimension . Some of their measurements (Table 1):
| Task and network | Parameters | |
|---|---|---|
| MNIST digits, fully connected | 199,210 | 750 |
| MNIST digits, LeNet (convolutional) | 44,426 | 290 |
| CIFAR-10 images, fully connected | 656,810 | 9,000 |
| CIFAR-10 images, LeNet | 62,006 | 2,900 |
| Inverted pendulum (reinforcement learning) | 562 | 4 |
Two things stand out. The numbers are small, and making the MNIST network wider or deeper barely changed . In the paper's words, every extra parameter “just ends up adding one dimension to the redundancy of the solution, ”. Bigger networks have bigger solution sets, not harder problems, and the authors suggest this may be one reason large models are easy to train.
Read beyond the course
Book · free online · ~60 min
Linear Algebra Done Right (4th edition)Sheldon Axler · Chapter 2: sections 2A (span and linear independence), 2B (bases) and 2C (dimension)
The cleanest treatment of this chamber's ideas, free under an open licence. Section 2C contains the proof that every basis has the same length, which this chamber took on trust. Read the definitions and examples first and the proofs second.
Book · free online · ~40 min
Mathematics for Machine LearningMarc Peter Deisenroth, A. Aldo Faisal & Cheng Soon Ong · Sections 2.4.3 (vector subspaces), 2.5 (linear independence) and 2.6.1 (generating set and basis)
The same ideas in machine-learning notation, with worked examples that test independence using Gaussian elimination. Read it now for the definitions, then return after Chamber 5 when the elimination steps will feel natural.
Lecture notes · free online · ~50 min
Lecture 9: Independence, basis, and dimensionGilbert Strang, MIT 18.06 · MIT OpenCourseWare, 18.06 Spring 2010
A classic lecture that covers this chamber in one sitting, with the video, a summary and a problem set. Strang connects independence to null spaces straight away, which is a preview of Chamber 6.
Interactive · free online · ~20 min
Immersive Linear Algebra: VectorsJ. Ström, K. Åström & T. Akenine-Möller · Section 2.5: vector bases and coordinates
Interactive figures where you drag basis vectors and watch coordinates change. A good way to make “same arrow, different ruler” feel physical.
Papers and lectures
The intrinsic-dimension paper is unusually readable, and you can get most of it today. Read the abstract. Then read Section 2 up to the end of Section 2.1, about two pages: the toy problem, Eq. (1), Eq. (2), and the paragraph on how is built (its columns are scaled to length 1 but not made exactly orthogonal). Look at Figure 1, then read the first two paragraphs of Section 3.1 and Table 1. Skip Section 2.2's thresholds, the reinforcement-learning section and the supplementary material for now. The short discussion of compressing a network to 750 numbers in Section 3.1 is a fun bonus.
Measuring the Intrinsic Dimension of Objective LandscapesChunyuan Li, Heerad Farkhoor, Rosanne Liu, Jason Yosinski · ICLR, 2018Trains networks in random subspaces of growing dimension to measure how many directions a problem really needs. Span, independence and dimension, applied to the weights of a neural network.
Intrinsic Dimensionality Explains the Effectiveness of Language Model Fine-TuningArmen Aghajanyan, Sonal Gupta, Luke Zettlemoyer · ACL, 2021Applies the same measurement to fine-tuning BERT and RoBERTa, and finds intrinsic dimensions as low as a few hundred for models with hundreds of millions of parameters. Section 3 opens by restating Li et al.'s method as a single equation, and Table 1 has the numbers; the rest can wait until after Chamber 6.
Decode the paper · Eq. (2), Section 2.1
Measuring the Intrinsic Dimension of Objective LandscapesChunyuan Li, Heerad Farkhoor, Rosanne Liu, Jason Yosinski · ICLR, 2018
The paper's recipe for training a network in a random subspace. Two of the three pieces on the right are random and frozen; only one is trained. Match each symbol to its job.
Options
Watch
Grant Sanderson animates exactly the picture from the lab: two vectors whose combinations sweep out the plane, until they line up and the span collapses to a line. Watch for the three-dimensional case in the second half, where a third vector either adds a new direction or stays trapped in the plane of the first two.
Your turn
You've met span, independence, bases and dimension. Now use them: match sets of vectors to their spans and notation to code, assemble a proof and write one, then solve three problems in code.
Match · Vectors ↔ Their span
What does the span look like?
Match each set of vectors to the shape of its span. Watch for vectors that add nothing new.
Options
Match · Maths ↔ Python
From symbols to NumPy
Match each piece of notation to the code that computes it. In the code, B holds the basis vectors as its columns, A holds as its columns, and c is a coordinate vector.
Options
Proofs
The first proof explains why coordinates in a basis are well defined: put its lines in order and leave out the two that don't belong. The second you write yourself.
Proof puzzle
Coordinates in a basis are unique
Claim
Let be a basis of a subspace . Then every can be written as in only one way.
Tap lines in the order they should appear. Not every line belongs. Tap a line in your proof to send it back.
Your proof
- Pick the first line below.
Available lines
Prove it yourself
Sum and difference stay independent
Claim
If and are linearly independent, then so are and .
Your typeset proof appears here.
Code it up
Three problems in the Project Euler style: each has a single answer. The second applies the intrinsic-dimension paper's toy problem, and the third runs the sifting algorithm from this chamber.
Problem 7·Warm-up
Independent pairs on a small grid
Let . Consider every ordered pair of vectors with and , where each of the four entries is chosen from . There are such pairs, including pairs with and pairs where a vector is .
How many of the 625 pairs are linearly independent, so that ?
Problem 8·Standard
Unfreezing one weight at a time
Li et al. (2018) warm up with a toy problem. There are parameters , split into 10 groups of 100 consecutive ones: group holds . A parameter vector is a solution when, for every , the parameters in group add up to exactly .
The paper trains in a dense random subspace, . Try a cheaper-looking alternative instead: unfreeze individual parameters one at a time. Start from . At step unfreeze parameter number , where
This sequence visits all 1000 indices without repeating, so after steps exactly parameters are free, and training may only move within the -dimensional subspace , where is the -th standard basis vector of .
What is the smallest for which this subspace contains a solution?
Problem 9·Challenge
Sifting redundant features
A dataset has 8 examples, indexed by . An eager engineer computes 15 features for each one. Feature gives the vector , where
Many of them are secretly redundant. Run the sifting algorithm from this chamber: go through in order, and keep if it is not in the span of the features kept so far (so is kept unless it is the zero vector). Otherwise discard it.
What is the sum of the indices of the features you keep?
Key takeaways
- The span of some vectors is every linear combination of them. It's always a subspace: a point, a line, a plane or more, through the origin.
- Independent vectors have no dead weight: only the all-zero combination gives . For two vectors in the plane, that's .
- A basis is independent and spanning, so every vector has unique coordinates in it. Changing basis changes the ruler, not the vector.
- Dimension is the size of any basis. In , more than vectors are dependent and fewer than can't span, and each independent linear equation removes one dimension.
- Networks have small intrinsic dimension: Li et al. trained in random subspaces and found that a few hundred directions often suffice, an idea that led to LoRA.
Checkpoint
Prove it to the labyrinth
Answer every question to clear this chamber. First-try answers earn the most XP.
In the basis , the vector has coordinates . What is ?
For which number are and linearly dependent?
Which list is a basis of ?
Which of these sets is not a subspace of ?
You have four vectors in . What can you conclude for certain?
A list of vectors includes the zero vector . Can the list be linearly independent?
Li et al. write . A model has parameters, and its solution set is a flat set of dimension . What is its intrinsic dimension ?
In the toy problem (, ten group-sum constraints, ), Li et al. train in random subspaces of increasing dimension . What do they observe?
End of the chamber
Clear this chamber
- Questions in this chamber (0/12 solved)Next unsolved
- Bonus: Span explorer (+40 XP)
- Bonus: Problem 7: Independent pairs on a small grid (+20 XP)
- Bonus: Problem 8: Unfreezing one weight at a time (+35 XP)
- Bonus: Problem 9: Sifting redundant features (+50 XP)
- Bonus: Proof: Coordinates in a basis are unique (+25 XP)
- Bonus: Proof: Sum and difference stay independent (+40 XP)
- Bonus: Decode the paper (+30 XP)
- Bonus: Match: What does the span look like? (+25 XP)
- Bonus: Match: From symbols to NumPy (+25 XP)