Simple Algorithm
Machine Learning · Descent · 22 min

Generalization in Modern ML

Interpolation, double descent and the puzzles deep networks raised.

Generations of textbooks taught one rule of thumb: never let a model reproduce noisy training labels exactly. Then networks with far more parameters than examples began fitting their training sets exactly, even with random labels, and predicting well anyway. This lesson shows what changed: test error can descend twice, the optimizer quietly chooses among countless perfect fits, and in high dimensions noise can be fitted harmlessly.

What you’ll learn

  • Contrast the classical U-shaped risk curve with the interpolation regime, and explain what the random-label experiments imply for complexity measures that ignore the data.
  • Describe the double-descent curve, locate the interpolation threshold, and explain the peak as the instability of a barely-possible fit.
  • Derive the minimum-norm interpolant X⊤(XX⊤)−1yX^\top(XX^\top)^{-1}\mathbf y and prove that gradient descent from zero converges to it.
  • Explain the intuition of benign overfitting, and separate what is established for linear and kernel models from what is open for deep networks.

The classical picture

The textbook story of model complexity is a trade-off. For squared loss, the expected test error at an input splits exactly into noise, squared bias and variance (Overfitting & the Bias–Variance Trade-off derives it):

E[(y−f^(x))2]=σ2+(f(x)−Ef^(x))2+Var⁡[f^(x)]\E\big[(y-\hat f(\mathbf x))^2\big]=\sigma^2+\big(f(\mathbf x)-\E\hat f(\mathbf x)\big)^2+\Var\big[\hat f(\mathbf x)\big]
The expectation is over training sets and test noise. Simple models have high bias; flexible ones have high variance; the sum traces a U as complexity grows.

Two assumptions hide in this picture: that the number of parameters measures complexity, and that fitting noisy labels exactly, interpolation, is fatal. Modern practice breaks both. The bias–variance identity itself never fails; what fails is the expectation that variance must explode once a model can fit everything.

Fitting noise, generalizing anyway

Zhang, Bengio, Hardt, Recht & Vinyals (2017) ran a randomization test on standard convolutional networks for CIFAR-10 and ImageNet. With every label swapped for a random one, the same networks still fit the training set (zero training error on CIFAR-10, and 95% top-1 training accuracy on ImageNet without any retuning); test accuracy fell to chance, as it must, and training took only a small constant factor longer. Even images replaced by pure noise were memorized. Explicit regularizers such as weight decay, dropout and data augmentation could improve test error but were, in their words, neither necessary nor by themselves sufficient for controlling generalization error.

They also showed why this is possible: a two-layer ReLU network with 2n+d2n+d parameters can represent any labeling of any nn points in Rd\R^d. So the same architecture, trained by the same algorithm, generalizes well on real labels and not at all on random ones.

Think first What do these experiments imply for generalization bounds based on VC dimension or Rademacher complexity of the architecture, or on the uniform stability of SGD?

All of them must be vacuous for these networks. A bound that depends only on the class (or only on the algorithm's hyperparameters, not the labels) has to hold on the random-label problem too, where the gap between training and test error is about 90% on ten balanced classes, so it cannot certify anything on the real labels. Empirical Rademacher complexity makes this concrete: it equals 1−2 E[ERM error on random labels]1-2\,\E[\text{ERM error on random labels}], which is the maximum, 1, here (Rademacher Complexity). An explanation must depend on the data and on which of the many perfect fits training actually finds.

Check your understanding

Which conclusion do the random-label experiments support?

  1. Deep networks do not really generalize; their good test scores are luck
  2. The VC dimension of these networks must be small
  3. Complexity measures that ignore the data and the labels cannot explain why the same networks generalize on real labels
  4. Explicit regularization is the main reason deep networks generalize
Show the answer

C. Complexity measures that ignore the data and the labels cannot explain why the same networks generalize on real labels

The same class and algorithm produce both a well-generalizing network (real labels) and a memorizing one (random labels), so whatever separates the two cases must involve the labels and the solution found. That rules out class-only and label-independent bounds as explanations.

Double descent

Belkin, Hsu, Ma & Mandal (2019) traced test error as model size grows past the interpolation threshold, the size at which a model can just fit the training set exactly. Below it, the familiar U. At the threshold, a peak. Beyond it, test error falls again, sometimes below the classical minimum: double descent. They demonstrated it for random features, two-layer networks and tree ensembles; Nakkiran, Kaplun, Bansal, Yang, Barak & Sutskever (2020) found it in deep networks as a function of width, of training time, and even of sample size, where adding data can hurt. Label noise makes the peak more pronounced.

Why a peak? At the threshold there is essentially one way to fit the data, and it is fragile: the design matrix is square and nearly singular, so tiny noise in the labels forces huge coefficients. Past the threshold there are infinitely many interpolants, and the minimum-norm one can spread the fit over more directions, so its norm, and its sensitivity to noise, falls as parameters are added. For isotropic Gaussian features this can be computed exactly.

Predict before you look

In that model, with signal r2=4r^2=4, noise σ2=1\sigma^2=1 and five times as many features as examples (γ=5\gamma=5), what is the limiting excess risk of the minimum-norm interpolant? (Predicting zero everywhere has excess risk r2=4r^2=4.)

Show the answer

3.45

r2(1−1/γ)+σ2/(γ−1)=4×0.8+1/4=3.45r^2(1-1/\gamma)+\sigma^2/(\gamma-1)=4\times0.8+1/4=3.45, better than the null predictor despite fitting the noise exactly. At γ=1.25\gamma=1.25 it would be 0.8+4=4.80.8+4=4.8, worse than predicting zero. In this model the overparameterized side beats the null risk only when the signal-to-noise ratio r2/σ2r^2/\sigma^2 exceeds 1, and then only for γ>SNR/(SNR−1)\gamma>\mathrm{SNR}/(\mathrm{SNR}-1) (Hastie et al., 2022).

The optimizer chooses the interpolant

With more parameters than examples, X∈Rn×pX\in\R^{n\times p} of rank n<pn<p, the perfect fits {w:Xw=y}\{\mathbf w:X\mathbf w=\mathbf y\} form an affine subspace of dimension p−np-n. The loss cannot tell them apart; the algorithm does. This preference of an optimizer among equally good fits is its implicit bias, and for least squares it can be computed exactly.

DerivationGradient descent from zero finds the minimum-norm interpolant
  1. w†=X⊤(XX⊤)−1y\mathbf w^\dagger=X^\top(XX^\top)^{-1}\mathbf y

    The target. Minimize 12∥w∥2\tfrac12\norm{\mathbf w}^2 subject to Xw=yX\mathbf w=\mathbf y. Stationarity of the Lagrangian gives w=X⊤ν\mathbf w=X^\top\boldsymbol\nu; substituting into the constraint, XX⊤ν=yXX^\top\boldsymbol\nu=\mathbf y, and XX⊤XX^\top is invertible because XX has rank nn:

  2. wt+1=wt−ηX⊤(Xwt−y)∈R(X⊤)\mathbf w_{t+1}=\mathbf w_t-\eta X^\top(X\mathbf w_t-\mathbf y)\in\mathcal R(X^\top)

    The iterates never leave the row space. Each step of gradient descent on 12∥Xw−y∥2\tfrac12\norm{X\mathbf w-\mathbf y}^2 adds a combination of the training inputs, so starting from w0=0\mathbf w_0=\mathbf 0 every iterate stays in R(X⊤)=span⁡{x1,…,xn}\mathcal R(X^\top)=\operatorname{span}\{\mathbf x_1,\dots,\mathbf x_n\}:

  3. lim⁡t→∞wt=w†=lim⁡λ→0+X⊤(XX⊤+λI)−1y\lim_{t\to\infty}\mathbf w_t=\mathbf w^\dagger=\lim_{\lambda\to0^+}X^\top(XX^\top+\lambda I)^{-1}\mathbf y

    The limit. With a step η<2/∥X∥2\eta<2/\norm X^2 the residual converges to zero, so the limit interpolates and lies in R(X⊤)\mathcal R(X^\top). Every interpolant is w†+z\mathbf w^\dagger+\mathbf z with z∈ker⁡X\mathbf z\in\ker X, the orthogonal complement of R(X⊤)\mathcal R(X^\top); staying in the row space forces z=0\mathbf z=\mathbf 0. By Pythagoras, ∥w†+z∥2=∥w†∥2+∥z∥2\norm{\mathbf w^\dagger+\mathbf z}^2=\norm{\mathbf w^\dagger}^2+\norm{\mathbf z}^2, so the limit is the shortest interpolant:

  4. The last equality says ridge regression with a vanishing penalty, written in its n×nn\times n form, reaches the same point: "ridgeless" regression and gradient descent from zero agree. Started at w0≠0\mathbf w_0\ne\mathbf 0, the component of w0\mathbf w_0 orthogonal to the row space never changes, so the initialization is part of the bias.

python
import numpy as np

rng = np.random.default_rng(0)
n, p = 20, 100                       # more parameters than examples
X = rng.standard_normal((n, p))
y = rng.standard_normal(n)           # pure noise: any interpolant fits it

w = np.zeros(p)                      # start at zero
eta = 1.0 / np.linalg.norm(X, 2)**2  # step size below 2 / ||X||^2
for _ in range(20_000):
    w -= eta * X.T @ (X @ w - y)     # gradient of 0.5 * ||Xw - y||^2

w_min = X.T @ np.linalg.solve(X @ X.T, y)   # minimum-norm interpolant
print(np.abs(X @ w - y).max())       # about 1e-17: the noise is fit exactly
print(np.linalg.norm(w - w_min))     # about 1e-16: GD found w_min

The two printed numbers are rounding errors: gradient descent from zero interpolates pure noise, and lands on exactly the minimum-norm interpolant among the infinitely many available.

Other losses and geometries have their own biases. With the logistic loss on data a hyperplane can separate, the weights of gradient descent grow without bound while their direction drifts, at the very slow rate O(1/log⁡t)\order{1/\log t}, toward the separator of largest margin (Soudry, Hoffer, Nacson, Gunasekar & Srebro, 2018). Mirror descent converges to the interpolant closest to its starting point in its own Bregman divergence; factorized models started near zero favor sparse or low-rank solutions; and the noise and large steps of SGD favor flatter regions of the loss. The Convergence lesson The Implicit Bias of Gradient Descent proves these results.

Check your understanding

In an underdetermined least-squares problem you multiply one feature by 10 before running gradient descent from zero. Does the learned prediction function change?

  1. No: rescaling a feature is undone by the matching coefficient, so every interpolant is unchanged
  2. No: gradient descent always finds the same function
  3. Only the training error changes
  4. Yes: a coefficient on the enlarged feature now costs ten times less norm per unit of effect, so the minimum-norm interpolant leans on that feature more
Show the answer

D. Yes: a coefficient on the enlarged feature now costs ten times less norm per unit of effect, so the minimum-norm interpolant leans on that feature more

The set of interpolating functions is unchanged, but the minimum-norm choice among them is not: in the original units the new solution minimizes ∑k≠jwk2+(wj/10)2\sum_{k\ne j}w_k^2+(w_j/10)^2, a different criterion. Implicit bias depends on the parameterization, which is why the widget's "minimum norm" refers to its own polynomial basis.

Benign overfitting: hiding noise in many directions

Fitting noisy labels exactly means the noise must go somewhere. Picture the fitted function as a smooth part plus narrow spikes at the training points: each spike absorbs one label's noise but covers almost none of the input space, so it barely affects new predictions. In linear models the spikes are many weak directions: when the features have a few strong directions and a long tail of many tiny, roughly equal ones, the minimum-norm interpolant fits the signal in the strong directions almost as ridge regression would, and spreads the noise thinly over the tail. This is benign overfitting.

Predict before you look

Features have 10 strong directions of variance 1 and a tail of 10610^6 directions of variance 10−510^{-5} each; there are n=1,000n=1{,}000 noisy examples. With k=10k=10, the tail is flat, so R10=106R_{10}=10^6. What is the noise factor k/n+n/Rkk/n+n/R_k?

Show the answer

0.011

10/1000+1000/106=0.01+0.001=0.01110/1000+1000/10^6=0.01+0.001=0.011: the interpolant pays about 1% of the noise variance, as if it had estimated 10 parameters, although it fits all 1,000 noisy labels exactly. The tail's total variance is 1010, small next to nn. Isotropic features in p=2np=2n dimensions would give n/R0=1/2n/R_0=1/2 instead: no tail to hide the noise in.

RegimeRisk as n→∞n\to\inftyExamples
Benigntends to the Bayes riskminimum-norm regression with benign spectra; Nadaraya–Watson smoothing with a singular kernel
Temperedtends to a constant above the Bayes risk1-nearest neighbor; piecewise-linear interpolation; ridgeless regression with Laplace or ReLU-NTK kernels; deep networks trained to interpolation (empirically)
Catastrophicgrows without bound (regression), or tends to chance (classification)polynomial interpolation through all nn points
The taxonomy of overfitting of Mallinar, Simon, Abedsoltan, Pandit, Belkin & Nakkiran (2022). In their experiments, networks trained to interpolate noisy labels were tempered, while the same networks stopped early were benign.
Check your understanding

A 1-nearest-neighbor classifier interpolates its training data. With noisy labels, its error converges to a value strictly between the Bayes error and chance. Where does it fall in the taxonomy?

  1. Benign
  2. Tempered
  3. Catastrophic
  4. None: classifiers that interpolate cannot be classified
Show the answer

B. Tempered

Tempered means the limit is above the Bayes risk but below chance: noise hurts by a bounded amount. For two classes the 1-NN error is asymptotically at most 2R⋆(1−R⋆)2R^\star(1-R^\star) (Consistency of Nearest Neighbors). Making it benign requires averaging over more neighbors, or interpolating with weights that are singular at the data points (Belkin, Hsu & Mitra, 2018).

What is understood, and what is not

PhenomenonEstablished (theorems)Open or only empirical
Double descentexact risk curves for linear and random-features models (Hastie et al., 2022; Mei & Montanari, 2022); optimal ridge removes the peak in isotropic linear models (Nakkiran, Venkat, Kakade & Ma, 2021)in deep networks, observed along width, epochs and samples; "effective model complexity" is a hypothesis (Nakkiran et al., 2020)
Implicit biasminimum norm for least squares; maximum margin for separable logistic regression; KKT points of a margin problem for homogeneous networks (Lyu & Li, 2020)which bias SGD has in realistic networks, and whether it explains generalization
Benign overfittinglinear regression (Bartlett et al., 2020); kernel ridgeless regression in high dimension (Liang & Rakhlin, 2020); some two-layer networks (Frei, Chatterji & Bartlett, 2022)interpolating deep networks look tempered rather than benign (Mallinar et al., 2022)
Kernel regimein the limit of infinite width with small steps, training is equivalent to kernel regression with a fixed kernel, the neural tangent kernel (Jacot, Gabriel & Hongler, 2018), which brings networks under the linear analysisreal networks move far from initialization and learn features, which the kernel description does not capture

Key takeaways

  • Networks that fit random labels make every complexity measure that ignores the data and labels vacuous; explanations must depend on which solution training finds.
  • Double descent: test error can peak at the interpolation threshold and fall again beyond it, as a function of model size, training time or sample size; tuned regularization removes the peak.
  • In the isotropic Gaussian model with p/n→γp/n\to\gamma, the shortest least-squares fit has limiting excess risk σ2γ/(1−γ)\sigma^2\gamma/(1-\gamma) for γ<1\gamma<1 and r2(1−1/γ)+σ2/(γ−1)r^2(1-1/\gamma)+\sigma^2/(\gamma-1) for γ>1\gamma>1; the blow-up at γ=1\gamma=1 is label noise magnified by a nearly singular design.
  • Started at the origin, gradient descent on an underdetermined least-squares problem ends at X⊤(XX⊤)−1yX^\top(XX^\top)^{-1}\mathbf y, the same point ridge reaches as λ→0+\lambda\to0^+; which solution an optimizer prefers changes with the loss, the update geometry, the parameterization and the starting point.
  • Benign overfitting hides noise in many weak directions; it is proved for linear and kernel models, while deep networks trained to interpolation look tempered, and a predictive theory for them is open.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

You keep adding parameters to a model that already fits its training data exactly, and its test error falls. What is the best explanation?

  1. Among the growing set of interpolants, the one the method returns has a smaller norm and is less sensitive to the noise
  2. The training error keeps decreasing
  3. Larger models are automatically regularized by the optimizer adding a penalty
  4. The bias–variance decomposition stops holding past the interpolation threshold
Show the answer

A. Among the growing set of interpolants, the one the method returns has a smaller norm and is less sensitive to the noise

Past the threshold, more parameters mean more ways to fit the same data, and minimum-norm-type solutions get smaller and smoother, so the variance term falls. Training error is already zero, nothing is added to the loss, and the decomposition still holds exactly.

Question 2

X∈Rn×pX\in\R^{n\times p} has rank n<pn<p. Gradient descent on 12∥Xw−y∥2\tfrac12\norm{X\mathbf w-\mathbf y}^2 starts at w=0\mathbf w=\mathbf 0 with a small step. Where does it converge?

  1. To (X⊤X)−1X⊤y(X^\top X)^{-1}X^\top\mathbf y
  2. To 0\mathbf 0
  3. Nowhere: with infinitely many minimizers the iterates drift forever
  4. To X⊤(XX⊤)−1yX^\top(XX^\top)^{-1}\mathbf y, the interpolant of minimum Euclidean norm
Show the answer

D. To X⊤(XX⊤)−1yX^\top(XX^\top)^{-1}\mathbf y, the interpolant of minimum Euclidean norm

Every gradient lies in the row space of XX, so the iterates do too; the only interpolant in the row space is X⊤(XX⊤)−1yX^\top(XX^\top)^{-1}\mathbf y, which is also the shortest one and the λ→0+\lambda\to0^+ limit of ridge.

Question 3

For which feature distribution can the minimum-norm interpolant of noisy labels predict almost as well as the best linear predictor, as nn grows?

  1. Isotropic features with twice as many features as examples
  2. A few strong directions plus a long tail of very many weak directions with small total variance
  3. Fewer features than examples
  4. A spectrum decaying like λk=k−2\lambda_k=k^{-2}
Show the answer

B. A few strong directions plus a long tail of very many weak directions with small total variance

The noise term is of order σ2(k⋆/n+n/Rk⋆)\sigma^2(k^\star/n+n/R_{k^\star}): it is small when few directions are important (k⋆≪nk^\star\ll n) and the tail has effective rank far beyond nn, while r0≪nr_0\ll n keeps the tail from distorting the strong directions.

Question 4

Your test error peaks sharply when the model is just large enough to fit the training set. Which remedy does theory support?

  1. Keep the model exactly at the threshold size
  2. Remove all regularization so the model can interpolate
  3. Tune a ridge penalty, or stop training early: optimally tuned ridge removes the peak in isotropic linear models
  4. Add label noise to the training set
Show the answer

C. Tune a ridge penalty, or stop training early: optimally tuned ridge removes the peak in isotropic linear models

The peak is noise amplified by a nearly singular fit. Ridge damps exactly those directions, and for isotropic Gaussian linear regression the optimally tuned ridge risk is monotone in both sample size and model size (Nakkiran, Venkat, Kakade & Ma, 2021). Moving well past the threshold also helps.

Go deeper

Further reading

  • C. Zhang, S. Bengio, M. Hardt, B. Recht & O. Vinyals, "Understanding deep learning requires rethinking generalization," International Conference on Learning Representations (2017).
  • M. Belkin, D. Hsu, S. Ma & S. Mandal, "Reconciling modern machine-learning practice and the classical bias–variance trade-off," Proceedings of the National Academy of Sciences 116(32), 15849–15854 (2019).
  • P. Nakkiran, G. Kaplun, Y. Bansal, T. Yang, B. Barak & I. Sutskever, "Deep double descent: where bigger models and more data hurt," International Conference on Learning Representations (2020).
  • P. L. Bartlett, A. Montanari & A. Rakhlin, "Deep learning: a statistical viewpoint," Acta Numerica 30, 87–201 (2021).