Generalization: double descent and implicit regularization
Before this lesson: lesson 02 (training and test error, the training loop) and lesson 06 (early stopping acts like ridge). Math: row space and null space in linear-algebra lesson 02, the SVD, the pseudoinverse and minimum-norm least squares in linear-algebra lesson 08, and random matrices in linear-algebra lesson 18 (only for one folded box). From other tracks: the bias–variance decomposition and the VC dimension (ML fundamentals track), and the step-size limit of gradient descent (optimization track). Time: about 100 minutes, plus the notebook. This is a heavy lesson. The folded boxes can be skipped on a first reading.
Why this matters #
ResNets and transformers usually have more parameters than training examples. They are trained to (almost) zero training loss. Classical statistics predicts that such models overfit. In practice they often generalize well, and a larger model is often better. Two experimental facts make the puzzle sharp:
- Double descent. The test error, as a function of model size, can go down, up, and down again (Belkin et al. 2019; Nakkiran et al. 2019). It also happens over training time and over the number of training samples: near the peak, more data can hurt.
- Random labels. A standard CNN fits CIFAR-10 with completely random labels to 100% training accuracy (Zhang et al. 2017). The same network on the real labels reaches about 86% test accuracy.
This lesson proves what can be proved for linear models (they are also the linearization of very wide networks), and gives the experimental facts for deep networks. As of 2026 there is no complete theory for deep networks. Interviews often ask: "Why do over-parameterized networks not overfit?", "What is double descent?", "Does gradient descent find the minimum-norm solution?". In ML for science, a surrogate fitted on 100 simulation runs with about 100 features sits exactly at the dangerous point. There the fitting rule (ridge, early stopping, the start of training) decides the result more than the number of parameters.
1. Predict first #
2. The picture #
One equation, two unknowns #
Take one training example with two weights: the equation . In matrix form, and . Every point on the line has zero loss . Which point does gradient descent find?
- The gradient is . The first factor is a number, the residual . So the gradient always points along , whatever is.
- The vector is the normal of the line (it is perpendicular to the line).
- So gradient descent moves only along the normal. From the origin it moves on the ray through .
- It stops where this ray meets the line: at . This is the point of the line closest to the origin, the solution with the smallest norm.
The loss does not prefer : every point of the line has loss 0. The algorithm prefers it. This is implicit regularization: the training procedure, not a penalty term, picks one of many equally good solutions. If we start at another point , gradient descent again moves along the normal, so it stops at the point of the line closest to .
Drag the violet start . The violet path is gradient descent; it always moves along , perpendicular to the aqua line of zero-loss solutions, so it lands on the point of the line closest to . From this is the minimum-norm solution (black). The dashed grey segment is the part of that gradient descent never changes. The orange arrow is the first step . Try above 0.4: the path diverges. Then switch on Adam (blue): it moves along and lands on a different solution.
One sample with noise #
Now take one unknown and one sample: fit with and the label , where is noise. The only solution is . The noise is multiplied by . A small input number makes the fit very sensitive to noise.
The same happens with many features when the number of features equals the number of samples . Then the square matrix must be inverted. Its smallest singular value is typically small, and the noise is divided by it. This point is the interpolation threshold: the model is just large enough to fit every training point, and it has exactly one way to do it.
Three regimes #
Keep fixed and let the number of features grow:
- (under-parameterized). Least squares averages the noise over many more equations than unknowns. More features lower the bias and raise the variance: the classical U-curve.
- (critical). There is one interpolant, and it is very sensitive to the noise. The test error peaks.
- (over-parameterized). There are many interpolants. The minimum-norm one spreads the fit over many directions. It has a small norm and amplifies the noise only a little. The test error falls again: the second descent.
Plotted against , the test error goes down, up, and down: model-wise double descent (the name is from Belkin et al. 2019). Training longer moves a large model through the same three regimes in time: epoch-wise double descent (Nakkiran et al. 2019, section 3.4 below).
Move the ridge and the label noise . We fit noisy points with frozen random ReLU features and plot the median test error over 6 random draws. The orange curve is the minimum-norm fit (): a U for , a peak at , and a second descent. The aqua curve is ridge with your : the peak disappears. Set : the peak gets smaller but stays, because the part of the target that the features cannot represent acts like noise. Set : now a larger is needed.
Gradient descent with a small step runs on from the start . Where does it stop?
, so is already on the zero-loss line. The residual is 0, so the gradient is 0 and gradient descent never moves. Gradient descent returns the minimum-norm solution only from (or from any start on the row space). In general it returns the solution closest to the start.
3. Definitions and main results #
3.1 Setting #
We have training pairs with . The can be raw inputs or features , for example random features. Stack them as rows of (row is , as everywhere in this track), and let . A linear model predicts with weights . The training loss is (a sum, not a mean; lesson 06 divides by ).
- An interpolant is a with , that is, with zero training loss. If and , interpolants exist for every . They form the set , a shifted copy of the null space , of dimension .
- The row space is the span of the rows . It is perpendicular to (linear-algebra lesson 02).
- The minimum-norm interpolant is , where is the pseudoinverse (linear-algebra lesson 08). It lies in the row space. It is also called ridgeless regression, because it is the limit of ridge regression as the penalty .
- With the SVD (singular values , , left and right singular vectors and ):
Read the last formula slowly: along each direction , the fit is the data coefficient divided by . A small singular value makes a large coefficient. This one formula explains the peak of section 3.3.
Implicit regularization (or implicit bias) is the preference of a training algorithm for some solutions over others that have the same training loss, without any penalty term in the loss.
3.2 Gradient descent finds the minimum-norm interpolant #
Theorem. Let with and . Run gradient descent from , with a step . Then , the unique interpolant with the smallest Euclidean norm.
Why this is true, in one sentence. Every gradient is a combination of the rows of , so gradient descent can never leave the row space; and the only interpolant inside the row space is the minimum-norm one.
Proof.
- The iterates stay in the row space. lies in . Every update adds , which is times a vector, so it lies in . Hence for some .
- The residual goes to zero. Let . Then . The matrix is symmetric positive definite (rank ), with eigenvalues . The eigenvalues of are . Because , they all lie in . So geometrically.
- The limit. , and is invertible, so and . This interpolates and lies in .
- It has the smallest norm. Any interpolant can be written with , so . Since , Pythagoras gives , with equality only for . So .
The condition is the usual step-size limit "(largest eigenvalue of the Hessian)" of the optimization track: here the Hessian is , and its largest eigenvalue is .
Corollary (nonzero start). From any , gradient descent converges to
the interpolant closest to . Here is the orthogonal projector onto the row space, and is the null-space part of .
Proof. Split into its row-space part and its null-space part . Every update lies in the row space, so the null-space part of stays forever. The row-space part follows the proof above (step 2 does not use ), so the limit is . It is the interpolant closest to , because lies in the row space and is therefore perpendicular to , the directions along the solution set.
So the algorithm and its start choose the solution. Fine-tuning a pretrained model starts at the pretrained weights, not at 0; in the linearized picture it returns the solution closest to them.
What else changes the chosen solution.
- SGD. A mini-batch gradient is also a combination of rows , so step 1 still holds. If SGD from 0 converges to an interpolant, it is (Zhang et al. 2017, section 5).
- A fixed preconditioner. Gradient descent with a fixed symmetric positive definite matrix , , is plain gradient descent in the variable . So from 0 it converges to the interpolant that minimizes , not .
- Adam. Adam divides each coordinate of the step by its own running scale . Its preconditioner changes at every step, so there is no general formula for its limit. When it converges to an interpolant, this is in general not the minimum-norm one. On the one-equation example it is exact: the gradient is always , so the second coordinate of is always twice the first, and the second coordinate of four times the first. The ratio is therefore the same in both coordinates: Adam moves along . From 0 it stops at , with squared norm . (This ignores Adam's tiny .)
Adam (with a decaying step) runs from on and converges. What is the squared norm of its limit, compared with ?
Adam scales each coordinate by its own . Here the gradient is always , so and every step is along . The path meets the line at , with . No interpolant is shorter than , so 3.3 is impossible. The minimum-norm result is special to gradient descent and SGD.
Other parametrizations, wide networks and other losses
- Parametrization. Write the same linear model as ( is the elementwise product) and run gradient descent on from , so that at the start. As , the limit becomes the minimum- interpolant, which prefers sparse ; as , the minimum- one (Woodworth et al. 2020). Same function class, same loss, different solution. In the notebook, with samples, weights and a truth with 3 nonzero weights: finds within 0.03 of the truth; returns , which is 2.12 away from it.
- Wide networks. Near its initialization , the outputs of a network on the training inputs are , where is the Jacobian with respect to the parameters. This is linear least squares in . So gradient descent returns the smallest change , by the corollary above. Very wide networks stay close to this linear model during training: the neural tangent kernel (NTK) regime.
- Logistic loss. On linearly separable data the logistic loss has no minimizer: . But the direction converges to the maximum-margin direction, the hard-margin SVM solution (Soudry et al. 2018).
- Finite steps. With a finite step , gradient descent follows, to first order in , the gradient flow of the modified loss (Barrett and Dherin 2021; Prince, Understanding Deep Learning, eq. 9.8). A larger step adds a stronger preference for flat regions.
3.3 The peak at the interpolation threshold #
Model. Assume a true linear model , where the noise has mean 0 and covariance . Test inputs are . The excess test risk of an estimate is
because . (The full test error adds the irreducible noise .)
Bias and variance of the minimum-norm fit, step by step.
- Put into : .
- is the orthogonal projector onto the row space. So is projected onto the row space, and .
- With the SVD, : the noise is divided by the singular values.
- Average over the noise. The cross term has mean 0, and . So
- For (full column rank), : there is no bias, and the variance is .
- For , the part of in is never seen by the data: this is the bias. The variance is .
- The peak. The variance is a sum of . For a random matrix with i.i.d. entries, the smallest nonzero singular value is about when and are large (linear-algebra lesson 18). At it is only of order . One tiny is enough to make the variance huge. Far from , every stays away from 0, and the variance is small.
Choose and move . First chart: the smallest singular value of a random Gaussian matrix (orange: median of 9 draws) against , and the large- prediction (aqua). It dips to almost 0 at . Second chart: the variance factor (orange, median) and its exact mean (aqua), which is infinite for . The yellow line marks your .
Exact risk for Gaussian features
Let the entries of be i.i.d. , independent of . Two facts about inverse Wishart matrices give the means of the variance term: for , and for . For the bias, use rotation invariance: the row space of is a uniformly random -dimensional subspace of , so the projector has mean , and . Together:
and for . For a fixed ratio and , the risk tends to for , and to for (Hastie, Montanari, Rosset and Tibshirani 2022). The same steps give the mean squared norm of the fit for : . It falls as grows: more features give more ways to interpolate, and the shortest one gets shorter.
Three facts that keep the picture honest (Hastie et al. 2022):
- In this well-specified model (the features contain everything the target uses), the best risk is in the under-parameterized regime, and for the risk tends to the null risk (the risk of always predicting 0). The second descent exists, but it does not win.
- When the model is misspecified (the target uses information that the features miss, as with random features), more features also lower the bias. Then the best risk can lie past the threshold, as in the widget above.
- Ridge with a well-tuned is better than the minimum-norm fit at every , and it has no peak. Ridge minimizes . In the SVD it replaces the factor by , which is never larger than (because ). So a tiny can no longer blow up the noise.
At , you replace the minimum-norm fit by ridge with a small . One singular value of is . By how much does the fit multiply the noise along that direction?
Ridge replaces by . The bound holds for every . So a tiny singular value can no longer amplify the noise, and the peak at disappears. The direction is shrunk, not removed: the factor is small but not 0.
3.4 Early stopping and epoch-wise double descent #
Lesson 06 showed that early stopping acts like ridge. Here is the same result in SVD form; it holds for any and . (In lesson 06, was an eigenvalue of ; here is a singular value of , so plays that role.)
- Let be the coefficient of along the right singular vector .
- Since and , the update gives the scalar recursion .
- Its factor is and its fixed point is . From :
The filter factor grows from 0 to 1. Direction needs about steps. Large singular directions are fitted first. The small ones, where amplifies the noise, come last. Stopping after steps acts like ridge with : both filters are near 1 for , and near for .
Epoch-wise double descent: one mechanism. For one group of directions, the test error over time is a U: it falls while the signal is fitted, and it rises while the noise is fitted. Now take two groups of features that learn at very different speeds. Two U-curves overlap in time:
- The fast features fit their own signal: the test error goes down.
- The fast features keep fitting the residual. It still holds the slow signal and the noise, which the fast weights cannot represent well. The fast weights grow in wrong directions: the test error goes up.
- Much later, the slow directions are learned. They take the slow signal out of the residual, and the fast weights are corrected: the test error goes down again.
Change the slow-feature scale and the noise , and move the stopping time . A linear model with 150 fast features and 5 slow features (variance ), , trained by gradient descent from 0 (computed exactly with the filter factors, average of 20 draws). The orange curve is the test error; the blue and violet curves are the parts from the fast and the slow weights. The shaded bands show how many steps each group needs, . With : down to 4.47, up to 7.77, and down to 0.87. With the speeds are close and the bump disappears.
Heckel and Yilmaz (2021) explain epoch-wise double descent in deep networks in the same way, with layers that learn at different speeds. They remove the bump by scaling the step size per layer. A practical lesson: keep the best checkpoint of the whole run, not the first local minimum of the validation curve.
3.5 Double descent in deep networks #
For a deep network, the horizontal axis is not exactly the number of parameters. Nakkiran et al. (2019) define the effective model complexity (EMC) of a training procedure (architecture, optimizer, number of epochs, data augmentation) as the largest number of samples on which it reaches an average training error of at most (they use ). Their hypothesis: if the EMC is well below or well above , anything that raises the EMC lowers the test error; if EMC (the critical regime), it may raise it. Their experiments:
- Model-wise. ResNet18s of growing width on CIFAR-10 and CIFAR-100, 5-layer CNNs, and transformers on IWSLT'14 translation show a peak where the models just reach zero training error. Label noise (for example 15% of labels changed at random) makes the peak much stronger. Without label noise there is often only a plateau, but sometimes a peak. Data augmentation and more samples move the peak to larger models.
- Epoch-wise. A large model's test error falls, rises and falls again during training. Medium models follow a U in time, and models too small to interpolate only improve.
- Sample-wise. More data moves the threshold to larger models. So near the threshold, more data can hurt: for some transformer sizes on IWSLT'14, training on 18k samples is worse than on 4k samples.
Belkin et al. (2019) found the peak at random Fourier features on MNIST, and at about parameters for a network with one hidden layer and outputs (the network must fit numbers).
3.6 Why capacity bounds cannot explain generalization #
Uniform convergence bounds. Let be the test (0–1) error of a classifier with values in , and its training error on samples. A standard bound (Mohri, Rostamizadeh and Talwalkar, Foundations of Machine Learning, chapter 3): with probability at least over the training set, for every in the class ,
where
is the training set and the are independent random signs. The Rademacher complexity measures how well the class can fit random labels on training inputs. VC bounds have the same form, with a term of order , where is the VC dimension of the class. These bounds depend on the class, not on the labels and not on the algorithm.
The random-label experiment (Zhang et al. 2017). An Inception network (1.65 M parameters) on CIFAR-10 ( images, 10 classes), without data augmentation or weight decay:
| labels | training accuracy | test accuracy |
|---|---|---|
| true | 100% | 85.75% |
| random | 100% | 9.78% (chance: 10%) |
Same architecture, same optimizer, same hyperparameters. The networks also fit images of random pixels. Inception V3 reaches 95.2% top-1 training accuracy on ImageNet with random labels (91.2% even with dropout and weight decay). Random labels make training slower only by a small constant factor.
Switch between training loss, training accuracy and test accuracy, and move the epoch. The same MLP (64–512–512–10, Adam) is trained on 500 images of the scikit-learn digits with true labels, with 50% random labels and with 100% random labels. All three reach 100% training accuracy; random labels need about three times as many epochs. Only the true labels give a good test accuracy. With 50% random labels, the test accuracy first rises to 0.90 (epoch 9) and then falls to 0.60 while the network memorizes the wrong labels.
The argument, step by step.
- If the class fits every labelling of the training inputs, then for every sign pattern some has , so the supremum is 1. Then and . The bound reads , which says nothing, since always .
- More generally, take any bound that holds for every data distribution. It must also hold for the random-label distribution. There the trained network has and , so .
- does not depend on the labels. So for the true labels, the same bound allows a test error of 0.90, while the real one is 0.14. The bound cannot tell the two cases apart, so it cannot explain the good one.
- Bounds based on the uniform stability of the algorithm fail for the same reason: they do not look at the labels either.
- So an explanation must depend on the data and on the solution that the algorithm actually returns (Zhang et al. 2017, section 2.2).
What the experiment does not show. It does not show that learning theory is wrong: the bounds are true, they are only too loose (vacuous) here. It does not show that data do not matter: random labels give chance test accuracy and take longer to fit. And "the network can fit random labels" is not "the network will fit noise": on real labels, gradient descent fits the simple, shared structure first (the fast directions of section 3.4) and memorizes the noise later (Arpit et al. 2017). The 50% curve in the widget shows this.
Partial answers (as of 2026). None of them is a complete explanation for deep networks.
- Implicit bias toward small-norm, max-margin or sparse interpolants (section 3.2). The norm alone does not predict the test error well (Zhang et al. note this).
- Bounds that depend on the solution found: norm-based, margin-based and PAC-Bayes bounds. Dziugaite and Roy (2017) computed non-vacuous PAC-Bayes bounds for small networks on MNIST.
- Flat minima. Solutions in wide, flat valleys tend to generalize. But flatness changes when the network is reparametrized, so it cannot be the full story.
- Benign overfitting. Fitting noisy labels exactly can be almost harmless when many directions with small variance absorb the noise (Bartlett, Long, Lugosi and Tsigler 2020).
- Inductive bias. The architecture (convolutions, attention, residual connections) matches the structure of real data.
A network fits CIFAR-10 with random labels to 100% training accuracy. What does this rule out?
A bound must hold for the random-label distribution too, where and . So , and the same cannot explain a test error of 0.14 on the real labels. The network does generalize well on real labels (85.75%), and the data clearly matter (random labels give chance accuracy). Implicit bias is one of the candidate explanations, not something the experiment rules out.
Answers to section 1. (1) is by far the worst: it is the interpolation threshold. Whether beats depends on the problem. In the random-features experiment of section 5 (, inputs in ), the far over-parameterized fit wins clearly (test error 0.10 against the best U value 0.49). With inputs in it does not quite win (0.142 against 0.125). In the well-specified Gaussian model of section 3.3, the second descent never beats the best small model. (2) Gradient descent returns the minimum-norm interpolant . From it returns : the null-space part of the start is kept. (3) No. The class can fit random labels, so any bound that depends only on the class must allow a test error near chance. An explanation must use the data and the algorithm.
4. Worked example #
A. The theorem by hand. One sample, two features: , .
- , so , with .
- The null space is spanned by (check: ). All interpolants are . Their squared norm is (the cross term is 0), which is smallest at .
- , so gradient descent converges for . Take . The residual is multiplied by at every step:
| residual | ||
|---|---|---|
| 0 | ||
| 1 | ||
| 2 | ||
| 3 |
In general : every iterate lies on the ray through , the row space.
- Start instead at . Its null-space part is . Gradient descent converges to . Check: ✓, and : the start added .
- Adam from 0 moves along : with , so and .
B. The peak in numbers. Gaussian features, , , , with the exact formula of section 3.3:
| 5 | 10 | 15 | 18 | 19–21 | 22 | 30 | 40 | 80 | 400 | |
|---|---|---|---|---|---|---|---|---|---|---|
| bias² | 0 | 0 | 0 | 0 | 0.091 | 0.333 | 0.500 | 0.750 | 0.950 | |
| variance | 0.089 | 0.278 | 0.938 | 4.50 | 5.00 | 0.556 | 0.263 | 0.085 | 0.013 | |
| risk | 0.089 | 0.278 | 0.938 | 4.50 | 5.09 | 0.889 | 0.763 | 0.835 | 0.963 |
- : variance . : bias , variance .
- Past the peak, the variance falls fast and the bias rises slowly. The second descent has a local minimum near . Then the risk climbs toward the null risk .
- The best risk overall is at the smallest (0.089 at ): this is fact 1 of section 3.3.
C. More data can hurt. Fix and add samples (same formula, now as a function of ):
| 20 | 30 | 37 | 43 | 60 | 100 | |
|---|---|---|---|---|---|---|
| bias² | 0.500 | 0.250 | 0.075 | 0 | 0 | 0 |
| variance | 0.263 | 0.833 | 4.625 | 5.000 | 0.526 | 0.169 |
| risk | 0.763 | 1.083 | 4.70 | 5.00 | 0.526 | 0.169 |
Going from 20 to 37 samples multiplies the risk by about 6, because moves toward . This is sample-wise non-monotonicity. For example, at the variance is .
A random-features surrogate has features and is fitted by minimum-norm least squares on 100 simulation runs. You add 15 new runs and the test error gets much worse. What is the most likely reason?
Near the interpolation threshold, more data can hurt (sample-wise double descent, part C). With and , the feature matrix is almost square, so its smallest singular value is close to 0. Check it, and check : both show the problem. The fix is ridge with chosen by cross-validation, early stopping, or a number of features far from . The model is still over-parameterized ().
5. In code #
The worked example A with NumPy, including Adam written by hand:
import numpy as np
X = np.array([[1.0, 2.0]]) # one equation: w1 + 2 w2 = 5
y = np.array([5.0])
X_pinv = np.linalg.pinv(X)
print(X_pinv @ y) # [1. 2.] the minimum-norm interpolant X⁺y
def gd(w0, eta=0.1, steps=200):
w = np.array(w0, dtype=float)
for _ in range(steps):
w = w - eta * X.T @ (X @ w - y) # gradient of ½‖Xw − y‖²
return w
print(gd([0, 0], steps=3)) # [0.875 1.75 ] = (1 − 0.5³)(1, 2)
w_lim = gd([1, 0])
P_null = np.eye(2) - X_pinv @ X # projector onto the null space N(X)
print(w_lim, X_pinv @ y + P_null @ np.array([1.0, 0.0])) # [1.8 1.6] [1.8 1.6]
print(round(w_lim @ w_lim, 3)) # 5.8 = 5 + 0.8
def adam(w0, lr=0.1, decay=0.995, steps=1500, b1=0.9, b2=0.999, eps=1e-8):
w, m, v = np.array(w0, dtype=float), np.zeros(2), np.zeros(2)
for t in range(1, steps + 1):
g = X.T @ (X @ w - y)
m, v = b1 * m + (1 - b1) * g, b2 * v + (1 - b2) * g**2
w = w - lr * decay ** (t - 1) * (m / (1 - b1**t)) / (np.sqrt(v / (1 - b2**t)) + eps)
return w
w_adam = adam([0, 0])
print(w_adam.round(4), (w_adam @ w_adam).round(3)) # [1.6667 1.6667] 5.556
The theorem with PyTorch's own optimizers, on a random problem with 5 equations and 12 unknowns:
import torch
torch.manual_seed(0)
n, p = 5, 12
X = torch.randn(n, p, dtype=torch.float64)
y = torch.randn(n, dtype=torch.float64)
w_mn = torch.linalg.pinv(X) @ y # minimum-norm interpolant X⁺y
P_row = torch.linalg.pinv(X) @ X # projector onto the row space
eta = 1.0 / torch.linalg.matrix_norm(X, 2).item() ** 2 # 1/s_1², inside (0, 2/s_1²)
def train(w0, make_opt, steps):
w = w0.clone().requires_grad_(True)
opt, sched = make_opt([w])
for _ in range(steps):
opt.zero_grad()
(0.5 * ((X @ w - y) ** 2).sum()).backward()
opt.step()
if sched: sched.step()
return w.detach()
sgd = lambda ps: (torch.optim.SGD(ps, lr=eta), None) # full-batch gradient descent
zero = torch.zeros(p, dtype=torch.float64)
w_gd = train(zero, sgd, 3000)
print(f"GD from 0: residual {(X @ w_gd - y).abs().max():.0e}, |w - X⁺y| {(w_gd - w_mn).abs().max():.0e}")
w0 = torch.randn(p, dtype=torch.float64)
w_gd0 = train(w0, sgd, 3000)
print(f"GD from w0: |w - (X⁺y + (I - X⁺X)w0)| {(w_gd0 - (w_mn + w0 - P_row @ w0)).abs().max():.0e}")
def adam(ps):
opt = torch.optim.Adam(ps, lr=1e-2)
return opt, torch.optim.lr_scheduler.ExponentialLR(opt, gamma=0.9995) # decay, so it settles
w_adam = train(zero, adam, 20000)
print(f"Adam from 0: residual {(X @ w_adam - y).abs().max():.0e}, ‖w‖ {w_adam.norm():.3f} "
f"vs ‖X⁺y‖ {w_mn.norm():.3f}, null-space part {(w_adam - P_row @ w_adam).norm():.3f}")
# GD from 0: residual 1e-16, |w - X⁺y| 3e-16
# GD from w0: |w - (X⁺y + (I - X⁺X)w0)| 1e-15
# Adam from 0: residual 3e-18, ‖w‖ 0.463 vs ‖X⁺y‖ 0.376, null-space part 0.270
Adam also interpolates, but it leaves the row space and returns a longer solution.
The exact risk formula of section 3.3 against a simulation (the table of part B):
import numpy as np
rng = np.random.default_rng(0)
n, s2 = 20, 0.25 # n = 20, σ² = 0.25, ‖β‖² = 1
exact = lambda p: s2 * p / (n - p - 1) if p < n else (1 - n / p) + s2 * n / (p - n - 1)
for p in [10, 15, 30, 40, 80]:
risk = []
for _ in range(4000):
beta = rng.standard_normal(p); beta /= np.linalg.norm(beta)
X = rng.standard_normal((n, p))
w = np.linalg.lstsq(X, X @ beta + np.sqrt(s2) * rng.standard_normal(n), rcond=None)[0]
risk.append(np.sum((w - beta) ** 2)) # excess test risk for x ~ N(0, I)
print(p, round(np.mean(risk), 3), round(exact(p), 3))
# 10 0.278 0.278
# 15 0.926 0.938
# 30 0.888 0.889
# 40 0.762 0.763
# 80 0.834 0.835
Model-wise double descent with frozen random ReLU features (; medians over 20 draws).
np.linalg.lstsq returns the minimum-norm solution when :
import numpy as np
from sklearn.linear_model import Ridge
ps = [2, 5, 10, 20, 30, 36, 40, 44, 50, 100, 400, 2000]
def random_features_curve(d, n=40, sigma=0.3, reps=20, seed=0):
"""Median test MSE of min-norm least squares (and ridge) on p frozen random ReLU features."""
rng = np.random.default_rng(seed)
beta = rng.standard_normal(d) / np.sqrt(d)
f = lambda x: x @ beta + 0.3 * np.tanh(x @ beta) # a mildly nonlinear target
out = {p: [] for p in ps}
for _ in range(reps): # new data and features each time
x_tr, x_te = rng.standard_normal((n, d)), rng.standard_normal((2000, d))
y_tr = f(x_tr) + sigma * rng.standard_normal(n)
W, b = rng.standard_normal((max(ps), d)) / np.sqrt(d), rng.uniform(-1, 1, max(ps))
for p in ps:
phi = lambda x: np.maximum(x @ W[:p].T + b[:p], 0) / np.sqrt(p) # p random ReLU features
F = phi(x_tr)
w = np.linalg.lstsq(F, y_tr, rcond=None)[0] # minimum-norm least squares
ridge = Ridge(alpha=1e-2, fit_intercept=False).fit(F, y_tr)
out[p].append([np.mean((phi(x_te) @ w - f(x_te)) ** 2),
np.mean((ridge.predict(phi(x_te)) - f(x_te)) ** 2),
np.linalg.svd(F, compute_uv=False)[min(n, p) - 1], # smallest nonzero s_i
np.linalg.norm(w)])
return {p: np.median(out[p], axis=0) for p in ps}
res = random_features_curve(d=10)
print(" p min-norm ridge s_min ‖w‖")
for p in ps:
print(f"{p:4d} {res[p][0]:9.3f} {res[p][1]:7.3f} {res[p][2]:8.4f} {res[p][3]:6.1f}")
res5 = random_features_curve(d=5)
best = min((p for p in ps if p < 40), key=lambda p: res5[p][0])
print(f"d = 5: best p < n is p = {best} with {res5[best][0]:.3f}; p = 2000 gives {res5[2000][0]:.3f}")
# p min-norm ridge s_min ‖w‖
# 2 0.796 0.796 2.0779 0.7
# 5 0.734 0.730 0.6498 2.5
# 10 0.576 0.571 0.2699 5.0
# 20 0.488 0.394 0.0879 12.6
# 30 0.824 0.291 0.0277 20.3
# 36 2.077 0.252 0.0111 41.2
# 40 14.372 0.224 0.0017 108.7
# 44 1.824 0.217 0.0113 43.1
# 50 0.837 0.176 0.0214 26.4
# 100 0.208 0.111 0.0582 14.1
# 400 0.110 0.072 0.0921 10.5
# 2000 0.099 0.063 0.0983 10.2
# d = 5: best p < n is p = 10 with 0.125; p = 2000 gives 0.142
All three regimes appear: a U with its bottom at , a peak at where the smallest singular value is tiny and the norm of is huge, and a second descent far below the U. A small ridge penalty removes the peak. With the second descent does not beat the U.
6. Where it shows up #
- Deep learning practice. Vision models are routinely trained to (almost) zero training error, and away from the critical regime bigger is better. Label noise makes the critical regime dangerous; there, tuned weight decay and ensembling help (Nakkiran et al. 2019 show the effect of ensembling). Language-model pretraining often uses each token about once, so the model does not interpolate its data. The peak matters mainly when a model is trained for many epochs on a fixed, small or noisy dataset: fine-tuning, and most scientific data.
- ML for science. Emulators are often fitted on – simulation runs with random features, kernel ridge regression or Gaussian processes. A Gaussian-process posterior mean with zero noise variance is the minimum-norm interpolant in the kernel's function space (the RKHS), the kernel version of the theorem of section 3.2. A nonzero noise variance (a "nugget") gives kernel ridge regression. The that counts is the number of independent runs, not the number of correlated grid points. When new runs move toward , re-tune the regularizer.
- Fine-tuning a foundation model (for example a weather or Earth-system model) on a few hundred events is deep in the over-parameterized regime. In the linearized picture, gradient descent returns the solution closest to the pretrained weights (the nonzero-start corollary).
- Early stopping. Because of epoch-wise double descent, the validation curve can rise and then fall again. Keep the best checkpoint of the whole run, not the first local minimum.
7. Common mistakes #
- "Double descent breaks the bias–variance decomposition." The decomposition holds at every . What fails is the idea that the variance always grows with the number of parameters: for the minimum-norm estimator it peaks at and then falls.
- "The peak is where the number of parameters equals the number of samples." For least squares with one output it is at features; with outputs, at about parameters. For deep networks it is where the whole training procedure just reaches zero training error (EMC ). This point moves with epochs, augmentation and label noise.
- "Past the threshold, bigger always wins." In the well-specified Gaussian model the second descent never beats the best small model, and a tuned ridge beats the ridgeless fit at every size.
- "Gradient descent finds the minimum-norm parameters of any network." The theorem is about linear least squares (and linearized networks) from . The implicit bias changes with the start, the parametrization, the optimizer (Adam leaves the row space) and the loss.
- "The VC bound is just loose by a constant." Here it is vacuous, and any bound that ignores the labels and the algorithm must be vacuous. This does not mean that the data do not matter: random labels give chance test accuracy and are fitted more slowly.
- "More data always helps." Near the threshold, more samples without re-tuning the regularizer can make the test error much worse (part C of section 4).
8. Check yourself #
- , . (a) Give the minimum-norm interpolant. (b) Where does gradient descent
converge from ?
Answer
(a) , so . (b) is spanned by and . The null-space part of is , so the limit is . Check: . - Same and . For which steps does gradient descent converge? What happens at from
?
Answer
, so . At the residual factor is : jumps between and , the residual alternates between and , and it never converges. (The average of the two points is the minimum-norm solution.) - Gradient descent from 0 with runs for steps. What fraction of the
minimum-norm coefficient is fitted along a direction with , and along one with ? Which
ridge gives about the same?
Answer
The filter factor is : about 1 for , and for . Ridge with gives and . - In the Gaussian model with , and , compute the risk at .
Is it on the rising or the falling side of the peak?
Answer
Bias , variance , risk . It is past the peak (), on the falling side: from 5.09 at to 0.889 at . - Zhang et al.: true labels give 85.75% test accuracy, random labels 9.78%, both with 100% training
accuracy. Show that no bound can explain the first number.
Answer
The bound must hold for every data distribution, including the random-label one. There and , so . does not depend on the labels, so for the true labels it allows a test error of 0.90 or more, while the real one is 0.14. Such a bound cannot separate the two cases; an explanation must use the data and the solution the algorithm returns. - Does Adam from on underdetermined least squares return the minimum-norm interpolant?
Answer
In general, no. Adam divides each coordinate of the step by its own , so the step leaves the row space and the limit has a null-space part. A fixed preconditioner would give the minimizer of ; Adam's preconditioner changes over time, so there is no closed form. In section 5: norm 0.463 against 0.376, null-space part 0.270. On it returns instead of .
What is the minimum-norm interpolant of (with , rank )?
: the only solution in the row space , and the one with the smallest Euclidean norm.
Why does gradient descent from 0 on end at the minimum-norm solution?
Every gradient is a combination of the rows of , so the iterates stay in the row space; the only interpolant in the row space is .
Where does gradient descent on underdetermined least squares converge from a start ?
To : the null-space part of never changes, so it returns the interpolant closest to .
What is implicit regularization?
The preference of a training algorithm (its start, optimizer, parametrization, step size) for some solutions among many with the same training loss, without a penalty term.
What is the interpolation threshold, and why is the test error high there?
The model size at which it can just fit all training points ( for least squares). There is one interpolant, the smallest singular value is near 0, and the noise is divided by it.
Bias and variance of the minimum-norm fit for , noise variance ?
Bias² (the part of in the null space); variance .
What is model-wise double descent?
Test error against model size goes down (classical U), peaks at the interpolation threshold, and goes down again for larger models.
What causes epoch-wise double descent in a linear model?
Two groups of directions that learn at very different speeds: the fast weights first fit their signal, then absorb noise and the slow signal (error rises), and the slow weights are learned much later (error falls again).
How does ridge change the noise factor of the minimum-norm fit?
It becomes , which is at most , so tiny singular values no longer amplify noise.
What does the random-label experiment (Zhang et al. 2017) show?
The same network fits random labels to 100% training accuracy, so bounds that depend only on the model class are vacuous; generalization must be explained with the data and the algorithm.
9. Interview angle #
- "What is double descent?" Test error against model size: a U, a peak at the interpolation threshold, and a second descent. It also appears over epochs and over the number of samples. It is strongest with label noise, and tuned regularization removes it.
- "Why is there a peak?" At there is exactly one interpolant. divides the noise by the singular values, and the smallest one, about , is near 0.
- "Prove that gradient descent finds the minimum-norm solution." The iterates stay in ; the residual contracts by ; the only interpolant in is ; Pythagoras gives minimality.
- "Why do huge networks generalize if VC theory says they should not?" Capacity bounds ignore the data and the algorithm, and the random-label experiment shows they are vacuous here. Current partial answers: implicit bias, norm, margin and PAC-Bayes bounds, benign overfitting, inductive bias of the architecture.
- "Is more data always better?" Not near the threshold without re-tuning the regularizer.
- "Is early stopping like L2 regularization?" For least squares, yes: the gradient-descent filter is close to the ridge filter with .
- "Does Adam have the same implicit bias as SGD?" No. Adam's per-coordinate scaling leaves the row space, so on least squares it does not return the minimum-norm interpolant in general.
10. Practice #
The notebook for this lesson runs in Colab. Each exercise has a check cell and a folded solution.
- Gradient descent from 0 and from on underdetermined least squares, compared with
np.linalg.pinvand the formula . - The double-descent curve with random ReLU features, with and without ridge.
- The smallest singular value of a random matrix against , compared with .
- A small MLP on the scikit-learn digits with random labels: 100% training accuracy, chance test accuracy.
- Adam against gradient descent on the same problem: the distance to the minimum-norm solution.
By hand: redo part A of section 4 with (answer: ), and part B with .
11. Watch and read #
- Simon Prince, Understanding Deep Learning, free PDF: §8.4 (double descent, with chapter notes on effective model complexity and epoch-wise double descent), §9.2 (implicit regularization of gradient descent and SGD, eqs. 9.8–9.9), §20.2 (fitting random data) and §20.4 (factors that determine generalization). The companion notebook 8.3 Double descent trains networks of growing width on MNIST-1D with label noise (it needs a GPU for about 30 minutes).
- Belkin, Hsu, Ma and Mandal, Reconciling modern machine learning practice and the bias-variance trade-off (PNAS, 2019).
- Nakkiran et al., Deep Double Descent: Where Bigger Models and More Data Hurt (2019): §2 (effective model complexity), §5 (model-wise), §6 (epoch-wise), §7 (sample-wise).
- Zhang, Bengio, Hardt, Recht and Vinyals, Understanding deep learning requires rethinking generalization (2017): §2 (random labels and pixels, Table 1), §4 (a two-layer ReLU network with weights can fit any labels of points in ), §5 (implicit regularization in linear models).
- Hastie, Montanari, Rosset and Tibshirani, Surprises in High-Dimensional Ridgeless Least Squares Interpolation (Annals of Statistics, 2022): the exact risk curves of section 3.3.
- Bartlett, Long, Lugosi and Tsigler, Benign overfitting in linear regression (PNAS, 2020).
- Arpit et al., A Closer Look at Memorization in Deep Networks (ICML, 2017): networks learn simple patterns first and memorize noise later.
- Heckel and Yilmaz, Early Stopping in Deep Networks: Double Descent and How to Eliminate it (ICLR, 2021).
- Soudry et al., The Implicit Bias of Gradient Descent on Separable Data (JMLR, 2018); Woodworth et al., Kernel and Rich Regimes in Overparametrized Models (COLT, 2020).
- Mohri, Rostamizadeh and Talwalkar, Foundations of Machine Learning, 2nd edition, free PDF: chapter 3 (Rademacher complexity and VC dimension).
Runs in your browser with nothing to install. The notebook repeats the key demos and has exercises with checks; solutions are inside, folded.