24.10 Uniform Convergence and Generalization
The previous section showed how to put an error bar on an average computed from data. A classifier evaluated on 10,000 held-out images has a true error within about 1.4 percentage points of its test error, with 95% confidence. That guarantee rests on a condition that is easy to overlook: the classifier must be fixed before the test images are drawn. In practice, we rarely work that way. We train many configurations, inspect their validation scores, and keep the best one. The score we report belongs to the winner of a contest, and the winner is partly the configuration that got luckiest on the sample.
Section 3.5 introduced this problem together with the remedy of Vapnik and Chervonenkis (Vapnik and Chervonenkis, 1971): demand a guarantee that holds for every candidate function simultaneously, so that it automatically covers whichever one the learner selects. When the list of candidates is finite, the bound widens only with the logarithm of the number of candidates. We briefly recall that finite-class result here and pair it with a concrete experiment that shows just how much luck there is to pick from: flip each of 1,000 fair coins 100 times and keep the coin with the most heads. How many heads does it show?
The heart of this section, however, is the infinite function classes we actually train. For them, a later idea measures the richness of a class by how well it can fit pure coin-flip labels, its Rademacher complexity. This measure explains why the capacity of a linear model depends on its weight norm rather than its parameter count, and it also reveals where uniform convergence reaches its limit: at models flexible enough to fit random labels, such as the deep networks of the main text. In the final part, we revisit the double-descent experiment of Section 4.5.2 in a model simple enough that we can compute every piece of the mechanism in closed form.
rng = np.random.default_rng()
24.10.1 Uniform Convergence#
Evaluating a fixed model on a test set and training a learner differ only in the order of two events: choosing the function and drawing the sample. Here we measure how much reversing that order distorts the score, and how much more data we need once the choice depends on the sample.
24.10.1.1 The Best of Many Coins#
Let us first state the single-function guarantee in the notation we will use throughout this section. A sample consists of independent draws from an unknown distribution, and a loss taking values in scores each prediction, for instance the 0-1 loss, which is for a mistake and otherwise.
The empirical risk of a function is its average loss on the sample, , while its risk is its expected loss on a fresh draw, . (For the 0-1 loss, these are the empirical error and population error of the main text.) When is fixed before is drawn, is an average of independent terms in with mean . Hoeffding's inequality (Section 24.9) therefore bounds by . Setting this failure probability to and solving for yields the half-width , which the main text calls the Hoeffding radius. For this gives , the 1.4 percentage points quoted above.
A learner reverses the order of events. It searches a class of functions and returns the predictor with the smallest empirical risk on the observed sample. Each fluctuates around its true risk , and the learner naturally picks a function whose random fluctuation happened to be favorable. Because is the minimum of many fluctuating quantities, an inequality that holds for each fixed individually no longer covers it.
Our coin-flipping experiment shows just how large this selection effect can be. Suppose we flip each of fair coins times. For a single coin named in advance, Hoeffding's inequality at allows a deviation of in the fraction of heads, so that coin lands between 37 and 63 heads with probability at least 95% (the exact probability is 99.3%). The best of the 1,000 coins carries no such guarantee. Let us repeat the experiment 2,000 times and measure how far the winning coin strays and how often it escapes the single-coin band.
k, m, repeats = 1000, 100, 2000 # coins, flips per coin, experiments
best = rng.binomial(m, 0.5, size=(repeats, k)).max(axis=1) / m
one = np.sqrt(np.log(2 / 0.05) / (2 * m)) # Hoeffding, one fixed coin
many = np.sqrt(np.log(2 * k / 0.05) / (2 * m)) # union bound over k coins
print(f'best of {k} coins: median {np.median(best):.2f}, 90% of experiments '
f'in [{np.percentile(best, 5):.2f}, {np.percentile(best, 95):.2f}]')
print(f'95% half-width: one coin {one:.3f}, all {k} coins {many:.3f}')
print(f'experiments in which the best coin leaves the one-coin band: '
f'{np.mean(best > 0.5 + one):.0%}')best of 1000 coins: median 0.66, 90% of experiments in [0.64, 0.69]
95% half-width: one coin 0.136, all 1000 coins 0.230
experiments in which the best coin leaves the one-coin band: 97%
In a typical experiment, the best coin shows 66 heads, and in nine experiments out of ten it lands between 64 and 69. It escapes the single-coin band in 96% to 97% of runs, so a guarantee that holds for every coin named in advance fails almost every time for the coin chosen afterwards. None of the coins is biased. The winner is off by 16 percentage points simply because we inspected 1,000 random fluctuations and kept the largest.
Figure 24.10.1 makes the reason visible. Any individual coin crosses the upper edge of the band with probability , a rare event on its own; among 1,000 coins, however, about are expected to do so. A tail that one coin almost never reaches becomes well populated once a thousand coins are tossed.
Expected histogram of the fraction of heads for 1,000 fair coins flipped 100 times each, shown on a logarithmic scale. Although the single-coin 95% Hoeffding band covers 99% of the coins, about 3.3 coins are expected above its upper edge, and the best coin typically lands near 0.66. The wider union-bound band for all 1,000 coins covers the best coin.
Model selection on a validation set is the exact same experiment with different labels: each configuration is a coin, and each validation example is a flip. Validation configurations share the same examples and have different true errors, unlike our independent fair coins, yet the bound we derive next requires neither independence across candidates nor equal means.
How, then, can we obtain a guarantee that still covers the chosen function? Suppose the largest deviation across the entire class,
is at most . Then every function's empirical risk lies within of its true risk, and in particular so does the function the learner picked. Bounds on this supremum are called uniform convergence bounds (Vapnik and Chervonenkis, 1971). Choosing after seeing the data becomes safe once the guarantee holds for all candidates before the data arrive, because whichever candidate we pick is already covered (Figure 24.10.2).
Uniform convergence. The empirical risk (orange) stays within of the true risk (blue) for every function in the class at once. The learner picks the minimizer of the empirical risk, which sits in a downward dip below the true risk. The band covers that function as well, so .
24.10.1.2 Finite Classes and the Union Bound#
The simplest setting is a finite list of candidates fixed in advance, such as a pre-specified grid of hyperparameter configurations. For this case the main text already stated the result in Section 3.5, and its proof takes only two lines. Hoeffding's inequality bounds the probability that a single fixed deviates by or more by . Applying the union bound (Section 24.9) across all candidates bounds the probability that any of them deviates by or more by . Setting this total failure probability equal to and solving for gives our first uniform convergence theorem: for a loss taking values in and an i.i.d. sample of size , with probability at least ,
Compared with evaluating a single fixed function, choosing among candidates adds inside the square root and nothing more.
On our coin experiment, setting and produces a half-width of , so with probability at least 95% every coin, the winning coin included, falls between 27 and 73 heads. The bound is admittedly conservative: the true probability that some coin falls outside 27 to 73 heads is about 0.17%, well below the 5% budget. Almost all of this factor-of-30 slack comes from Hoeffding's inequality on a single coin, which leaves that range with probability where Hoeffding allows ; the union bound itself is nearly tight for rare independent events. Conservative or not, the band is valid, whereas the single-coin band was not.
For a validation set of 10,000 examples, the main text records the half-widths: for a single function and for a million. Solving (24.10.1) for the sample size makes the cost of searching more transparent:
Each additional unit of requires more examples. At a tolerance of , doubling the number of candidate models costs extra validation examples.
This logarithmic dependence is a direct gift of Hoeffding's exponential tail. If we used Chebyshev's inequality instead (noting that a -valued loss has variance at most ), the same union bound would yield . For 2,000 configurations on 10,000 examples at , Chebyshev gives , spanning the entire range of the loss and telling us nothing, whereas Hoeffding gives .
The proof relies on one crucial hypothesis in its very first step: the candidate class must be fixed before the sample is drawn. A public benchmark leaderboard violates this assumption whenever each new submission is chosen after inspecting the test scores of earlier ones (Dwork et al., 2015). Once the candidates adapt to the holdout set, the error guarantee degrades from order for fixed candidates to order for an adaptive majority vote built from random guessers (exercise 5).
24.10.2 Rademacher Complexity#
The function classes we actually train are infinite. Every weight vector defines a distinct linear classifier, and a union bound over infinitely many events is vacuous. Classical learning theory gets around this either by approximating the class with finitely many representatives (covering numbers) or by counting how many distinct labelings it can realize on points (the VC dimension, sketched in Section 3.5). Here we take a more direct approach (Bartlett and Mendelson, 2002) that asks an operational question any practitioner can test: how well can the class fit pure noise?
The two central results of this section live in this part: the uniform convergence theorem (24.10.3) and the complexity bound for norm-bounded linear models, (24.10.5). The one subtle step is the symmetrization argument in the proof of the first.
24.10.2.1 Correlation with Random Signs#
If a function class can fit labels that carry no signal at all, it can just as easily fit the noise in real labels, and its empirical risk then tells us very little about its true risk. To test a class's capacity for memorizing noise, we feed it fictitious random labels. Let be independent fair random signs, each taking the value or with probability ; these are called Rademacher variables. For a given sign vector , the average measures how well correlates with those signs on the sample, and the supremum over measures the best correlation the class can achieve.
Definition. The empirical Rademacher complexity of a class of real-valued functions on the sample points is the expected best correlation the class achieves with random signs,
and its Rademacher complexity is the average of this quantity over random samples of size .
A class that can match any sign pattern scores high, whereas a class with little freedom scores near zero. The exact ceiling depends on the range of the functions. If every takes values in , then every correlation is at most , and the class of all functions into achieves on distinct points by setting for every sign pattern. For a class taking values in , the maximum possible complexity is : the best choice sets wherever and elsewhere, scoring the fraction of plus signs, which averages to . An unbounded class, such as the linear functions we study shortly, has no such ceiling: if it can interpolate every sign pattern on the sample, its complexity is at least , and can be larger still.
To get a feel for the numbers, consider the simplest nontrivial class: the two constant functions . Its best correlation with a sign vector is , where is the sample average of the signs. For , the four equally likely patterns give , so . For , the sum of the signs is with probability , with probability , and otherwise, giving . For large , is approximately normal with mean and variance , so ; at , the exact value is compared with from the normal approximation. Even a class with just two functions correlates with noise at rate , simply because the average of random signs fluctuates at that scale. By contrast, a singleton class has complexity : with nothing to choose from, .
For a linear class, the best correlation has a clean geometric interpretation, previewed in Figure 24.10.3: it is the length of a signed sum of the input vectors, divided by . We prove this shortly in Section 24.10.2.3.
Rademacher complexity of a linear class for eight unit vectors in the plane and the class of unit-norm linear functions. (a) For a single sign pattern, filled dots denote and hollow dots . The best correlation is achieved by the unit weight vector aligned with the signed sum , and equals . (b) The exact distribution of the best correlation across all 256 sign patterns. Its mean, the empirical Rademacher complexity, is 0.316, compared with the bound proved in the text.
A finite class taking values in satisfies Massart's lemma, (exercise 2), so its complexity grows only logarithmically with the number of functions. More generally, Rademacher complexity captures how freely a class can vary on the actual sample points, regardless of how many parameters or members it has.
24.10.2.2 The Uniform Convergence Theorem#
We are now ready to show that Rademacher complexity controls the largest gap between empirical risk and true risk across the entire class. One small bookkeeping distinction comes first, because predictions and losses belong to different function classes. The predictor class contains the models we fit, whereas the quantities whose averages we compare are the losses. We therefore define the loss class
whose functions take values in . Writing for a labeled example, let and for . The risk of a predictor is simply the risk of its corresponding loss function.
Proposition (uniform convergence via Rademacher complexity) (Bartlett and Mendelson, 2002). Let be an i.i.d. sample and let be a class of functions taking values in . Then with probability at least ,
Notice that this bound has the exact same three-part anatomy as the finite-class bound: the empirical risk on the training sample, a complexity term measuring the richness of the class, and a confidence term that would appear even for a single fixed function. Here, the richness term is twice the class's ability to fit random signs.
Proof. We first bound the expected worst-case gap, , in three steps; the high-probability statement follows from concentration.
I. Ghost sample. Introduce an independent copy of the sample , which serves purely as an analytical device inside the proof. Because , and because the supremum of an expectation is always at most the expectation of the supremum, we obtain
The unknown population risk has been replaced by the empirical risk on a fresh sample.
II. Sign swap. Swapping with leaves the joint distribution of completely unchanged, since both points are independent draws from the same distribution. Yet that swap negates the -th difference for every simultaneously. Consequently, for any fixed choice of signs , multiplying the -th difference by does not change the right-hand side of (24.10.4). Averaging over random signs leaves it unchanged as well:
III. Split. Since the supremum of a sum is at most the sum of the suprema, the right-hand side is bounded above by
because has the same distribution as , making both expectations equal to . This split is where the factor of comes from.
To pass from the expectation to a high-probability bound, define . Replacing a single sample point changes each empirical risk by at most (since takes values in ), and therefore changes the supremum by at most . McDiarmid's inequality (McDiarmid, 1989), which generalizes Hoeffding's inequality from sums to any function that no single input can shift by much, then gives (exercise 1). Setting the right-hand side to and combining with yields (24.10.3).
The intuition behind this symmetrization argument is remarkably clean. The ghost sample stands in for the population. Because real and ghost points are exchangeable, swapping any pair changes nothing in distribution, and once those swaps are randomized, only coin flips remain: the worst-case gap between training and population risk is governed by how well the class can chase random signs.
One practical detail remains. The theorem states the bound in terms of the expected complexity , whereas on a real dataset we can only evaluate the empirical complexity on the sample at hand. Because changing one sample point also moves by at most , a second application of McDiarmid's inequality lets us substitute for in (24.10.3) at the cost of widening the confidence term to . Our numerical checks below use this empirical form.
It is always worth checking a theorem at its extremes. For a singleton class, and (24.10.3) reduces directly to one-sided Hoeffding. For a finite class, Massart's lemma recovers the shape of (24.10.1), though with looser constants: for 2,000 configurations on 10,000 examples, the complexity term alone is , compared with the union bound's entire half-width of . Rademacher complexity pays a constant-factor penalty on finite classes, in exchange for handling infinite classes effortlessly. For binary classifiers, counting the labelings realizable on points bounds by a constant times (Boucheron et al., 2005), where is the VC dimension from the main text, the largest number of points on which the class can realize every possible labeling.
At the opposite extreme, any loss class taking values in satisfies . When equality holds, the complexity term equals , and the bound becomes vacuous, allowing any risk up to 100%. For binary classifiers taking values in under the 0-1 loss , the loss complexity and predictor complexity stand in an exact factor-of-two ratio. Expanding the correlation gives . The first sum has mean zero and does not depend on , while for fixed labels , the products are again independent fair random signs. Taking the supremum and expectation yields
Therefore, if a binary predictor class can fit every sign pattern on the sample, we have , twice the loss complexity is , and the uniform convergence theorem promises nothing better than an error rate below 100%.
24.10.2.3 The Linear Class#
A generalization theorem is only as useful as our ability to evaluate its complexity term on classes we actually care about. For linear predictors with a bounded weight norm, the calculation takes just four lines, and its answer is surprisingly independent of the input dimension.
Proposition (Rademacher complexity of a norm-bounded linear class). Let and suppose every sample input satisfies . Then
Proof. The inner supremum has a closed form. By linearity of the inner product and the Cauchy--Schwarz inequality, the maximum is attained by the weight vector of length pointing in the direction of the signed sum:
Taking the expectation over yields the equality in the proposition. To obtain the upper bound, invoke the concavity of the square root () and expand the squared norm:
All cross terms vanish because independent fair signs satisfy for . Multiplying by gives .
Panel (a) of Figure 24.10.3 illustrates the first step of this proof: for any sign pattern, the optimal weight vector simply aligns with the signed sum of the inputs.
Remarkably, only one step in this proof introduces any slack. Because the identity is exact, the entire gap comes from replacing the mean length of the signed sum by its root-mean-square length. That inequality is tight whenever the length varies little across sign patterns. For the eight points in the figure, the slack is 11% ( versus ). In two dimensions, a signed sum of many well-spread unit vectors behaves like a two-dimensional Gaussian vector, whose mean length is times its root-mean-square length, so the slack stays near 11% regardless of . In twenty dimensions, however, the length of the signed sum concentrates tightly around its root-mean-square by the thin-shell phenomenon of Section 24.9.2.1, and the slack drops to about 1%.
Notice what is missing from (24.10.5): the input dimension does not appear at all. It enters only indirectly through and . In this bound, the capacity of a linear model is governed by the product of its weight norm and its input radius, whether it operates on ten features or on a million. This gives a clean theoretical motivation for weight decay (Section 2.7): keeping small shrinks the function class that contains the trained model. Nor is this dimension-free behavior restricted to linear models: a two-layer ReLU network whose output weights have norm at most and whose hidden weight vectors have norm at most has Rademacher complexity at most , regardless of its width (exercise 8).
A careful reader may raise a natural objection: the proposition requires fixing the radius before seeing the data, whereas the norm of a trained weight vector is known only after training. That objection is valid, and a union bound over a ladder of radii resolves it. Apply the theorem to each radius with failure probability (which sum to ), and evaluate the bound at the smallest containing the fitted weight vector. For , this costs at most a factor of in the complexity term and adds a mild penalty (exercise 3).
One link remains before we can turn (24.10.5) into a generalization bound for linear classifiers. The uniform convergence theorem requires the complexity of the loss class , whereas our proposition bounded the predictor class . A Lipschitz loss bridges the two.
Lemma (contraction) (Boucheron et al., 2013). Let each be -Lipschitz. Then for any function class and points ,
In plain terms, composing a function class with transformations that stretch distances by at most can multiply its Rademacher complexity by at most . Allowing each to be different is precisely what a supervised loss requires: at example , is the map with the label held fixed. No centering condition is needed, because adding a constant to shifts the sum by , which has expectation zero. We state the contraction lemma without proof.
The uniform convergence theorem also requires losses bounded in . Common training losses such as hinge and logistic loss are unbounded: on our norm-bounded linear class they can reach roughly , so applying the theorem directly would require dividing by that maximum and bounding a rescaled loss. A cleaner choice for analysis is a loss that is bounded from the outset: the ramp loss applied to the classification margin ,
The ramp loss equals on a mistake (), drops to once a prediction is correct by at least the margin (), and interpolates linearly in between. It upper-bounds the 0-1 loss everywhere and is -Lipschitz, as Figure 24.10.4 shows.
The ramp loss (blue) as a function of the margin , together with the 0-1 loss (dashed). The two agree except for (shaded), where a prediction is correct by less than the margin and the ramp descends with slope .
Write for the empirical ramp loss on the sample. When every input satisfies , combining the contraction lemma with our linear-class proposition bounds the loss-class complexity by . Plugging this into (24.10.3) yields a margin bound: with probability at least , simultaneously for every with ,
The left-hand side is the true classification error rate, while the right-hand side is the training ramp loss plus two computable terms. To see the scale of these numbers, take an illustrative setting with , , and (choosing the ratio rather than measuring it on a specific dataset). The complexity term is and the confidence term is , totaling . Thus, with fixed in advance, any linear classifier in the class that separates its training set with margin is guaranteed, with 95% confidence, to have a true error rate below . By contrast, forcing a linear model to fit random labels with margin drives upward: past the two penalty terms exceed , and near the complexity term alone reaches , rendering the bound vacuous.
24.10.2.4 Rademacher Complexity in Numbers#
Because (24.10.5) expresses the empirical Rademacher complexity of a linear class as an expected Euclidean norm, we can estimate it directly by averaging over random sign vectors. Below we do this for 50 unit-norm points in , , and dimensions. Our slack analysis predicts an estimate roughly 11% below the bound in two dimensions, and within about 1% of the bound once we reach twenty dimensions.
n, B, num_signs = 50, 1.0, 2000
signs = rng.choice([-1.0, 1.0], size=(num_signs, n)) # rows: sign vectors
for d in (2, 20, 1000):
X = rng.standard_normal((n, d))
X /= np.linalg.norm(X, axis=1, keepdims=True) # ||x_i|| = r = 1
sup_corr = B * np.linalg.norm(signs @ X, axis=1) / n # closed-form sup
print(f'd = {d:4d}: Monte-Carlo R_S = {sup_corr.mean():.3f}, '
f'bound B r / sqrt(n) = {B / np.sqrt(n):.3f}')d = 2: Monte-Carlo R_S = 0.123, bound B r / sqrt(n) = 0.141
d = 20: Monte-Carlo R_S = 0.141, bound B r / sqrt(n) = 0.141
d = 1000: Monte-Carlo R_S = 0.141, bound B r / sqrt(n) = 0.141
The Monte Carlo estimate lands around in the plane and between and in 20 and 1,000 dimensions, right against the bound of , just as predicted. Increasing the dimension fifty-fold from 20 to 1,000 leaves the complexity unchanged.
At the opposite end of the spectrum lies a class rich enough to interpolate, meaning it can reproduce any assignment of labels on the training sample exactly. Consider least squares on standard Gaussian features, where the feature matrix holds the feature vectors of the points as rows. Using the pseudoinverse from Section 21.5.3.1, the solution returns the minimum-norm interpolant for every sign vector , achieving a correlation of on every pattern by construction. Our proposition tells us how large a weight ball is needed to hold all of these fits: any class that interpolates every sign pattern must have , while (24.10.5) bounds it by , so any ball containing all the interpolants must satisfy . How close to this lower limit do actual fits come? Next, we fit 2,000 random sign vectors, compare their weight norms with the theoretical prediction (derived in exercise 4), and evaluate for the smallest ball enclosing them.
p = 2 * n # more features than points
Phi = rng.standard_normal((n, p))
W = np.linalg.pinv(Phi) @ signs.T # min-norm fit of each sign vector
w_norm = np.linalg.norm(W, axis=0)
r = np.linalg.norm(Phi, axis=1).max() # input radius: largest row norm
row_norm = np.linalg.norm(Phi, axis=1).mean()
print(f'mean ||w|| = {w_norm.mean():.2f} (predicted '
f'{np.sqrt(n / (p - n - 1)):.2f}), largest {w_norm.max():.2f}')
print(f'typical fit: mean ||w|| * mean row norm / sqrt(n) = '
f'{w_norm.mean() * row_norm / np.sqrt(n):.2f}')
print(f'r = {r:.1f}, B r / sqrt(n) with B = largest ||w||: '
f'{w_norm.max() * r / np.sqrt(n):.1f}')mean ||w|| = 0.99 (predicted 1.01), largest 1.31
typical fit: mean ||w|| * mean row norm / sqrt(n) = 1.40
r = 12.4, B r / sqrt(n) with B = largest ||w||: 2.3
Each fit has a weight norm near , and the rows of have average length near , placing a typical fit at . Across 2,000 sign patterns, the largest weight norm falls between and and the longest row between and , so the ball enclosing all 2,000 fits has between and . Interpolating pure noise therefore requires a norm only 1.5 to 3 times the theoretical floor: the linear-class bound remains nearly tight even in the regime where it ceases to be informative.
The same arithmetic applies directly to neural networks. Consider the class of all classifiers a given architecture can represent. Whenever training on random signs finds a function matching them at nearly every point, the supremum in (24.10.2) is close to for that ; if this happens for typical sign vectors, the Rademacher complexity itself is close to . In Section 4.5.1.1, an MLP fit random labels on its training images with zero error, mirroring the image-classification experiments of Zhang et al. (2021). (Those experiments tested a few labelings with ten classes, so they are empirical evidence rather than a formal proof.) Twice the loss-class complexity is then close to , and (24.10.3) allows any test error whatsoever. Yet the very same network generalizes well when trained on real labels. Whatever governs its test error is therefore invisible to any worst-case bound over the entire function class: it depends on the data, the optimizer, and the specific solution training reaches. To see how that works, we turn to a model where the learned solution can be analyzed in closed form.
24.10.3 Interpolation and Double Descent#
In Section 4.5.2, we swept the width of a network whose hidden layer remained frozen at its random initialization. The test error spiked at , the exact threshold where interpolation first became possible and the smallest singular value of the hidden representation collapsed, and then descended again as grew further. Here we recreate that construction on synthetic data where every piece of the mechanism can be computed explicitly, adding two ingredients to the main text's account: a closed-form formula for the fitted weights in terms of singular values, and a decomposition of the test error into the part caused by the true target and the part caused by label noise. The features are with a frozen random matrix , known as a random-features model (Rahimi and Recht, 2007), and we fit only the linear output head . Readers on a first pass may skip this part without losing the thread of the chapter.
24.10.3.1 The Minimum-Norm Interpolant#
To understand why the interpolation threshold behaves so dramatically, let us write the solution in closed form. With features and training points, stack the training feature vectors as the rows of , and fit . Below , this is ordinary least squares; above , it is the interpolant of smallest Euclidean norm.
The minimum-norm interpolant is not an arbitrary choice among the many interpolants: it is the one that training finds. The gradient of the squared loss, , is a combination of the training feature vectors, so gradient descent started at never leaves the row space of . The only interpolant in that row space is , and gradient descent converges to it without any penalty on the norm. This preference of an optimizer for one solution among many that fit the data equally well is called its implicit bias.
The singular value decomposition illuminates all three regimes: below, at, and above the threshold. Suppose has full rank and singular value decomposition , with . Then the pseudoinverse solution is
Each component of along a left singular vector is divided by its singular value , so the smallest singular value acts as the strongest amplifier. Whatever component of falls along enters magnified by , and this amplification hits both label noise and the part of the true target that the features approximate poorly.
When , the fitted predictions simply project onto the -dimensional span of the , leaving the remainder as training residual. At , however, those directions span all of : the fit becomes exact, and no residual is left to absorb the poorly represented component. A square random ReLU-feature matrix is almost surely invertible, yet rarely well conditioned: its smallest singular value is typically tiny, and by the condition-number analysis of Section 21.5.3.2, the solution shoots far out along . Adding features beyond gives the matrix extra room to span , and climbs back up.
Past the threshold, the solution norm can only decrease as we add features, provided the feature sets are nested (the -feature model keeps all previous features and appends one more). This follows from the padding argument of Section 4.5.2: assigning weight zero to the new feature turns the minimum-norm -feature interpolant into a valid -feature interpolant of identical norm, so the new minimum norm can be no larger. Notice that this monotonicity relies on exact interpolation. Below , the least-squares fit does not interpolate, and its norm actually grows with : in the sweep below, it climbs from roughly at to nearly at .
Our linear-class bound suggests a natural quantity to monitor along the sweep: the capacity product , which corresponds to for the smallest ball containing the fitted weights. We borrow it purely as a diagnostic, not as a formal bound, because this sweep uses squared loss on unbounded regression targets rather than a bounded classification loss. Past the threshold, the feature radius grows like while shrinks, so the product's net behavior is not obvious in advance.
24.10.3.2 A Double-Descent Sweep#
Let us watch these quantities move together on a concrete problem. We draw
training points from a linear teacher
in dimensions, with
and Gaussian label noise of standard deviation
. We construct nested ReLU random features and fit the linear head via
pinv, giving least squares below and the minimum-norm interpolant
above it. We sweep from to , including , , and
so the threshold peak is sharply resolved. At each , we log the test
MSE, training MSE, , , and the capacity
product, along with the two components of test error analyzed in
Section 24.10.3.3: the clean part (the test error
of fitting noise-free labels) and the noise part (the additional test
error injected by label noise). Taking medians across 20 independent trials
keeps the curves readable.
n, n_test, d_in, p_max, trials, noise = 40, 500, 15, 400, 20, 0.1
p_grid = np.array([2, 5, 10, 15, 20, 25, 30, 35, 38, 39, 40, 41, 42, 45, 50,
60, 80, 120, 200, 400])
keys = ('test', 'train', 'norm', 's_min', 'capacity', 'clean', 'noise',
'ratio_q', 'ratio')
stats = np.zeros((len(keys), trials, len(p_grid)))
ols = np.zeros(trials) # least squares on x itself
for tr in range(trials):
beta = rng.standard_normal(d_in)
beta /= np.linalg.norm(beta) # teacher: y = <beta, x>
X, X_te = (rng.standard_normal((size, d_in)) for size in (n, n_test))
y_clean, y_te = X @ beta, X_te @ beta
y = y_clean + noise * rng.standard_normal(n) # noisy training labels
ols[tr] = np.mean((X_te @ np.linalg.lstsq(X, y, rcond=None)[0] - y_te) ** 2)
V = rng.standard_normal((p_max, d_in)) / np.sqrt(d_in)
Phi, Phi_te = np.maximum(X @ V.T, 0), np.maximum(X_te @ V.T, 0)
for j, p in enumerate(p_grid): # nested feature prefixes
F, F_te = Phi[:, :p], Phi_te[:, :p]
P = np.linalg.pinv(F) # least squares / min norm
w = P @ y
r = np.linalg.norm(F, axis=1).max() # feature radius
_, S, Vt = np.linalg.svd(F, full_matrices=False)
ratio = ((np.linalg.norm(F_te @ Vt.T, axis=0) ** 2 / n_test)
/ (S ** 2 / n)) # test/train feature power
stats[:, tr, j] = (
np.mean((F_te @ w - y_te) ** 2), # test MSE
np.mean((F @ w - y) ** 2), # training MSE
np.linalg.norm(w), # ||w||
S.min(), # sigma_min
np.linalg.norm(w) * r / np.sqrt(n), # capacity
np.mean((F_te @ (P @ y_clean) - y_te) ** 2), # clean part
noise ** 2 * np.linalg.norm(F_te @ P) ** 2 / n_test, # noise part
ratio[-1], ratio.mean()) # along v_q, average
med = dict(zip(keys, np.median(stats, axis=1)))
The figure below plots the medians of test MSE, solution norm, and the capacity product on logarithmic axes.
d2l.plot([p_grid] * 3 + [[n, n]],
[med['test'], med['norm'], med['capacity'], [1e-2, 1e2]],
'number of random features p', 'median over 20 runs',
legend=['test MSE', '||w||', 'capacity', 'p = n'], xscale='log',
yscale='log', fmts=('-', 'm--', 'g-.', 'k:'), figsize=(6, 3.5))The table below prints the full breakdown at seven representative feature counts. Its final two columns belong to Section 24.10.3.3, and the last line reports the classical baseline that fits least squares directly on the raw inputs.
print(' p ' + ' '.join(f'{key:>8}' for key in keys))
for p in (15, 38, 40, 42, 50, 80, 400):
row = [med[key][p_grid == p][0] for key in keys]
print(f'{p:4d} ' + ' '.join(f'{v:8.2g}' for v in row))
print(f'least squares on the {d_in} raw inputs: test MSE {np.median(ols):.4f}') p test train norm s_min capacity clean noise ratio_q ratio
15 0.65 0.28 1.9 1 1.3 0.67 0.0066 3.7 1.8
38 3.3 0.0081 5.5 0.08 6 2.9 0.31 6.8e+02 32
40 71 2.3e-28 29 0.016 34 58 4.2 1.5e+04 4.2e+02
42 3.4 1.3e-29 6 0.076 6.5 2.9 0.26 5.8e+02 26
50 0.74 6.6e-30 2.7 0.25 3.1 0.64 0.063 62 6.3
80 0.22 7e-30 1.3 0.71 1.8 0.19 0.021 10 2.1
400 0.049 5.3e-30 0.4 2.6 1.3 0.04 0.0095 2.3 0.95
least squares on the 15 raw inputs: test MSE 0.0066
The table reads best in three regimes: below the threshold, at the threshold, and beyond it.
Below the threshold, the model behaves classically, with fewer parameters than training points. Its test error first drops from roughly at to about – near , and then climbs again as approaches , tracing the familiar classical U-curve. Two caveats are essential before we compare anything against this regime. First, even at its best, this classical fit is weak: the targets have variance (the error of always predicting zero), so the minimum of the U-curve removes no more than about a third of the variance. Second, a far better classical model exists. Because the true teacher is linear in the 15 raw inputs, ordinary least squares on those raw inputs has expected test error (the noise variance times for ), confirmed by the last line of the output. The random-features model is handicapped by design: it must reconstruct a linear function from ReLU ridges, and forty points are far too few for that.
At the threshold, three columns move in lockstep. The training error plummets from a few times at to roughly , exact interpolation up to floating-point precision. Simultaneously, the smallest singular value drops to around –, several times smaller than at or . Because (24.10.8) divides by , the solution explodes: jumps to between and , and test MSE spikes to between and , one to two orders of magnitude above the U-curve minimum. Those ranges are wide because the peak is heavy-tailed, just as for a square Gaussian matrix where ; even a median over 20 trials fluctuates noticeably from run to run.
Beyond the threshold, everything that spiked comes back down. The smallest singular value recovers to roughly at . As the padding argument guarantees, declines monotonically in every trial (not just in the medians), reaching roughly . Test MSE follows it downward, to about at and – at . Meanwhile, one column goes completely silent: training error sits at zero (up to floating point) everywhere past , so no criterion based on training loss can tell apart from , even though their test errors differ by more than an order of magnitude. The solution norm, , and the capacity product all distinguish them clearly.
What, then, does this sweep actually prove? Less than the dramatic curve might suggest at first glance. Within the nested family of random features, the widest model beats every narrower one, including the best underparameterized model, by roughly a factor of ten, even far past the point where it memorizes all label noise. That is a genuine and surprising phenomenon. Yet it still loses to ordinary least squares on the raw inputs by another factor of ten. Whether an interpolating model can outperform a well-specified small model is a separate question, and here the answer is no.
The capacity product peaks near 10 to 35 at and drops back to roughly – at . It mirrors the shape of the test curve, but we should not mistake it for a generalization certificate: no theorem in this section covers unbounded squared loss, the product is not invariant to rescaling the targets, and was read off the fitted solution rather than fixed before seeing the data.
Finally, notice that label noise is not what causes the peak. Rerunning
the sweep with noise = 0 produces a peak of almost the same height, and
the table shows why: at , the clean part of the test error is already
larger than the noise part, typically several times larger. Because a linear
teacher cannot be written as a finite combination of ReLU features, the
approximation error along is what divides. If
we replace the teacher with an exact linear combination of the first ten
features and remove the noise, the peak disappears altogether (exercise
6).
24.10.3.3 Benign Overfitting#
One puzzle remains. At , the model interpolates every noisy training label with zero residual, yet it achieves the lowest test error in the sweep. Why does fitting the noise do so little damage there?
We can answer this by splitting the test error into two computable parts. Write the noisy training labels as , where are the noise-free labels and is independent noise with variance per example. By linearity of the pseudoinverse, , so the test predictions split into . Because has mean zero, the cross term vanishes in expectation, leaving an exact decomposition of the expected test MSE over test points:
The clean and noise columns of our table print these two terms. At
, the noise part is roughly to (a hundred times or more the
label-noise variance of ), and the clean part is larger still. By
the noise part drops to a few tenths, at to about , and
at to just under . Over the same stretch, the clean part
falls from roughly 8–60 at the peak to about at , so most of
the improvement past the threshold comes from approximating the target
better.
Why does dividing by small singular values, the very mechanism that created the spike at , become nearly harmless at ? By (24.10.8), a noise component along enters the weights scaled by along , and shifts a test prediction in proportion to the test feature's component along . Using together with , the noise part for takes the illuminating form
the noise variance multiplied by the average ratio of mean-squared test
feature energy to mean-squared training feature energy along each right
singular direction . A tiny singular value only
causes trouble when test inputs carry substantial energy in that same
direction. At , a tiny is an accident of the forty
training points: along , the test features are typically
thousands of times larger in mean square than the training features. At
, by contrast, a small marks a direction where the
features are small for training and test points alike. The final
two columns of the table confirm this: ratio_q (along ) is
only about , and ratio (averaged over all directions) sits just below
, so the small denominator is cancelled by a small numerator. This is
the sense in which overfitting is called benign. Notice that benign means
bounded, not zero: at , the predictions still carry roughly the
variance of a single noisy training label.
Bartlett et al. (2020) make this phenomenon precise for linear regression through two effective ranks of the input covariance matrix, which exercise 7 computes directly. In deep neural networks, the features themselves are learned and their spectrum evolves throughout training, so a first-principles theory that predicts a trained network's test error remains out of reach. Every formal bound in this section covers the worst function in a class chosen before seeing the data, whereas the predictor we deploy is the specific solution an optimizer finds. Bridging that gap, with guarantees that depend on the algorithm and the data rather than on the function class alone, is the central open question this section leaves behind.
24.10.4 Summary#
A concentration bound for a single function fixed before the data does not cover a model chosen because it scored best on the sample. Uniform convergence closes that gap by bounding the estimation error of every function in the class simultaneously. For a finite class , Hoeffding's inequality and the union bound achieve this at a cost of additional examples at tolerance . For infinite classes, symmetrization with a ghost sample reduces the worst-case gap to correlation with random signs, adding twice the Rademacher complexity of the loss class to the empirical risk. For norm-bounded linear models (, ), this complexity is at most , independent of dimension. Uniform convergence reaches its boundary on classes flexible enough to interpolate arbitrary sign patterns, such as deep networks that fit random labels, where the bound becomes vacuous. Our random-features sweep illustrates why generalization can still succeed in that regime: test error spikes where collapses and falls as the minimum-norm interpolant shrinks, properties of the learned solution rather than of the whole function class.
24.10.5 Exercises#
- McDiarmid's inequality. ● The inequality of McDiarmid (1989) extends Hoeffding's from sums to functions with bounded differences. Suppose that changing only the -th argument of moves its value by at most , and that are independent. Then
and the same bound holds for the lower tail. Take this statement on faith; its proof uses martingales.
- Recover Hoeffding's inequality for an average of independent terms from it.
- Let for a loss class with values in . Show that has bounded differences . Combine McDiarmid's inequality with the symmetrization bound of the text and derive (24.10.3).
- For data in , the sample mean has bounded differences . Construct a sample of odd size in in which changing one point moves the sample median by . What does this imply for using McDiarmid's inequality to put an error bar on the bootstrap estimate of the median in Section 24.5?
-
Massart's lemma and balls. ● Massart's lemma for finite classes and the Rademacher complexity of -bounded linear classes rest on one bound for the expected maximum of sub-Gaussian variables.
- Let be centered and sub-Gaussian with variance proxy , that is, for all , but not necessarily independent. Show that by bounding by and optimizing over . Deduce Massart's lemma, , for a finite class with values in .
- Let and for all . Follow the proof of (24.10.5), with the duality in place of Cauchy--Schwarz, and show that . Why does the dimension now enter, and why only logarithmically?
- Let the inputs lie in and let the target weight vector have nonzero entries, each equal to . Compare the bound of (b) with (24.10.5), each with the smallest radius that contains the target. For which is the bound smaller when ?
-
Margin bound. ● Let with , let the labels be , and let the ramp loss with a fixed act on the margin .
- Show that is at least the 0-1 loss and that is -Lipschitz. Show that multiplying each prediction by a fixed label leaves unchanged.
- Combine (a), the contraction lemma (24.10.6), (24.10.3), and (24.10.5) into (24.10.7). For and , find the largest ratio for which the complexity and confidence terms together stay below .
- The bound holds for a radius fixed before the data are drawn, whereas the norm of a trained weight vector is known only afterwards. Apply the bound with radius and confidence for every , and take a union bound over . State the bound that holds for a weight vector with chosen after seeing the data. Show that the freedom to choose the radius costs at most a factor in the complexity term and an additional term of order .
-
[code] Fitting random signs. ● The second cell of Section 24.10.2.4 fits sign vectors with on standard Gaussian features and measures the norms of the fits.
- Let and let have full column rank. Show that the correlation has expectation over the signs. The matrix is a projection.
- Let , let be the largest row norm of , and let be large enough that the class contains an interpolant of every sign vector. Explain why cannot then be smaller than . For a standard Gaussian with , . Use this identity to predict the typical , and the typical value of times a typical row norm of divided by , as functions of and .
- Rerun the cell with for (for print the correlation instead of the norm) and compare with (a) and (b). What happens to the capacity value of (b) as , and why does the version with the largest row norm stay above ?
-
[code] Leaderboard attack. ●● A leaderboard reports the 0-1 loss of each submitted label vector on a holdout set of examples with labels . The boosting attack of Blum and Hardt (2015) uses no knowledge of the task: submit uniformly random label vectors, keep those with reported loss at most , and submit their coordinatewise majority vote. On fresh data, the majority vote has loss .
- Implement the attack for uniformly random and , and record the reported loss of the majority vote. Compare its distance from with the deviation that (24.10.1) allows for a pre-registered pool of models at . From which on does the attack exceed this deviation, and which hypothesis of the proposition does it violate?
- Blum and Hardt (2015) prove that the reported loss is but do not give the constant. Derive it heuristically with Gaussian approximations: estimate the expected excess agreement with of a kept vector, then the probability that the majority of about such vectors is correct on one coordinate. Compare the constant with the measurements of (a).
- The Ladder mechanism of Blum and Hardt (2015) releases a new score only when a submission beats the best released score by more than a step , rounds it to a multiple of , and otherwise repeats the previous score. Against the Ladder, the attacker can only keep the vectors that lowered the released score. Implement both for and . How far below does the majority vote now get, and how does this compare with the deviation of (a)?
-
[code] The square case. ● Use the sweep of the double-descent experiment in Section 24.10.3.2.
- Show from the stored norms that the nesting monotonicity fails below the threshold, and explain why the padding argument does not apply there.
- At , decompose along (24.10.8). Report, as a median over trials, the coefficient of the smallest singular direction next to . Which share of the norm does this one direction carry?
- Rerun the sweep with
noise = 0. Then replace the teacher by a target that is an exact combination of the first ten features, with and no noise. Describe the two curves. In each case, what does divide? Why does the minimum-norm interpolant become worse as features are added when the target uses only ten of them? - Add label noise of standard deviation to the target of (c). Where is the test error now highest, how does the peak compare with the noise variance, and where is the error lowest?
-
[extended] Benign spectra. ●● Bartlett et al. (2020) characterize when the minimum-norm interpolant in linear regression has small excess risk, the mechanism that Section 24.10.3.3 describes in words. Let with and , let with , stack training inputs into , and let . The excess risk is .
- Show that its expectation over the noise is the sum of a bias term , where , and a variance term . Implement both terms; no test set is needed.
- The paper's effective ranks are and . With the smallest such that , the variance term is of order up to constants; take . Use , , five strong directions with that contain a unit-norm , and weak directions with each, for . Compare the measured variance with . What happens at , and why?
- Repeat with power-law spectra truncated at , for , , and . For which spectra does the excess risk decrease with ? For the others, does the bias or the variance fail, and how do , , and show it?
-
Norms, not widths: a two-layer network. ●● Let and , on points with .
- Show that .
- Show that is contained in times the convex hull of , and that taking the convex hull of a class does not change its empirical Rademacher complexity. Hint: .
- Using , show that , and conclude that .
- The width does not appear in the bound. What does the bound say about weight decay on both layers? Why does it not explain the random-label experiment of Section 4.5.1.1?