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 S={(x1,y1),…,(xn,yn)}S=\{(\mathbf x_1,y_1),\ldots,(\mathbf x_n,y_n)\} consists of nn independent draws from an unknown distribution, and a loss ℓ\ell taking values in [0,1][0,1] scores each prediction, for instance the 0-1 loss, which is 11 for a mistake and 00 otherwise.

The empirical risk of a function ff is its average loss on the sample, R^(f)=1n∑i=1nℓ(f(xi),yi)\hat R(f)=\frac1n\sum_{i=1}^n\ell(f(\mathbf x_i),y_i), while its risk is its expected loss on a fresh draw, R(f)=E[ℓ(f(x),y)]R(f)=\mathbb{E}[\ell(f(\mathbf x),y)]. (For the 0-1 loss, these are the empirical error ϵS(f)\epsilon_\mathcal{S}(f) and population error ϵ(f)\epsilon(f) of the main text.) When ff is fixed before SS is drawn, R^(f)\hat R(f) is an average of nn independent terms in [0,1][0,1] with mean R(f)R(f). Hoeffding's inequality (Section 24.9) therefore bounds P(∣R^(f)−R(f)∣≥t)P(|\hat R(f)-R(f)|\ge t) by 2e−2nt22e^{-2nt^2}. Setting this failure probability to δ=0.05\delta=0.05 and solving for tt yields the half-width log⁡(2/δ)/(2n)\sqrt{\log(2/\delta)/(2n)}, which the main text calls the Hoeffding radius. For n=10,000n=10{,}000 this gives 0.01360.0136, the 1.4 percentage points quoted above.

A learner reverses the order of events. It searches a class F\mathcal F of functions and returns the predictor f^\hat f with the smallest empirical risk R^\hat R on the observed sample. Each R^(f)\hat R(f) fluctuates around its true risk R(f)R(f), and the learner naturally picks a function whose random fluctuation happened to be favorable. Because R^(f^)\hat R(\hat f) is the minimum of many fluctuating quantities, an inequality that holds for each fixed ff individually no longer covers it.

Our coin-flipping experiment shows just how large this selection effect can be. Suppose we flip each of k=1,000k=1{,}000 fair coins m=100m=100 times. For a single coin named in advance, Hoeffding's inequality at δ=0.05\delta=0.05 allows a deviation of log⁡40/200=0.136\sqrt{\log 40/200}=0.136 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 0.00330.0033, a rare event on its own; among 1,000 coins, however, about 3.33.3 are expected to do so. A tail that one coin almost never reaches becomes well populated once a thousand coins are tossed.

Figure 24.10.1:

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,

sup⁡f∈F ∣R^(f)−R(f)∣,\sup_{f\in\mathcal F}\ \bigl|\hat R(f) - R(f)\bigr|,

is at most tt. Then every function's empirical risk lies within tt 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).

Figure 24.10.2:

Uniform convergence. The empirical risk R^(f)\hat R(f) (orange) stays within tt of the true risk R(f)R(f) (blue) for every function in the class at once. The learner picks the minimizer f^\hat f of the empirical risk, which sits in a downward dip below the true risk. The band covers that function as well, so R(f^)≤R^(f^)+tR(\hat f)\le\hat R(\hat f)+t.

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 ff deviates by tt or more by 2e−2nt22e^{-2nt^2}. Applying the union bound (Section 24.9) across all ∣F∣|\mathcal F| candidates bounds the probability that any of them deviates by tt or more by 2∣F∣e−2nt22|\mathcal F|e^{-2nt^2}. Setting this total failure probability equal to δ\delta and solving for tt gives our first uniform convergence theorem: for a loss taking values in [0,1][0,1] and an i.i.d. sample of size nn, with probability at least 1−δ1-\delta,

∣R^(f)−R(f)∣≤log⁡(2∣F∣/δ)2nsimultaneously for every f∈F.(24.10.1)\bigl|\hat R(f) - R(f)\bigr| \le \sqrt{\frac{\log(2|\mathcal F|/\delta)}{2n}} \qquad\textrm{simultaneously for every } f\in\mathcal F . \tag{24.10.1}

Compared with evaluating a single fixed function, choosing among ∣F∣|\mathcal F| candidates adds log⁡∣F∣\log|\mathcal F| inside the square root and nothing more.

On our coin experiment, setting ∣F∣=1,000|\mathcal F|=1{,}000 and n=100n=100 produces a half-width of log⁡(2,000/0.05)/200=0.230\sqrt{\log(2{,}000/0.05)/200}=0.230, 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 1.7×10−61.7\times10^{-6} where Hoeffding allows 5×10−55\times10^{-5}; 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: 0.0140.014 for a single function and 0.0300.030 for a million. Solving (24.10.1) for the sample size nn makes the cost of searching more transparent:

n=log⁡(2/δ)+log⁡∣F∣2t2.n=\frac{\log(2/\delta)+\log|\mathcal F|}{2t^2}.

Each additional unit of log⁡∣F∣\log|\mathcal F| requires 1/(2t2)1/(2t^2) more examples. At a tolerance of t=0.01t=0.01, doubling the number of candidate models costs log⁡2/(2⋅10−4)≈3,500\log 2/(2\cdot 10^{-4})\approx3{,}500 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 [0,1][0,1]-valued loss has variance at most 14\tfrac14), the same union bound would yield t=∣F∣/(4nδ)t=\sqrt{|\mathcal F|/(4n\delta)}. For 2,000 configurations on 10,000 examples at δ=0.05\delta=0.05, Chebyshev gives t=1t=1, spanning the entire range of the loss and telling us nothing, whereas Hoeffding gives t=0.024t=0.024.

The proof relies on one crucial hypothesis in its very first step: the candidate class F\mathcal F 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 log⁡k/n\sqrt{\log k/n} for kk fixed candidates to order k/n\sqrt{k/n} for an adaptive majority vote built from kk random guessers (exercise 5).

24.10.2 Rademacher Complexity#

The function classes we actually train are infinite. Every weight vector w∈Rd\mathbf w\in\mathbb{R}^d 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 nn 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 Br/nBr/\sqrt n 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 ε1,…,εn\varepsilon_1,\ldots,\varepsilon_n be independent fair random signs, each taking the value +1+1 or −1-1 with probability 12\tfrac12; these are called Rademacher variables. For a given sign vector ε\boldsymbol\varepsilon, the average 1n∑iεif(xi)\frac1n\sum_i\varepsilon_if(\mathbf x_i) measures how well ff correlates with those signs on the sample, and the supremum over f∈Ff\in\mathcal F measures the best correlation the class can achieve.

Definition. The empirical Rademacher complexity of a class F\mathcal F of real-valued functions on the sample points S=(x1,…,xn)S=(\mathbf x_1,\ldots,\mathbf x_n) is the expected best correlation the class achieves with random signs,

R^S(F)=Eε ⁣[ sup⁡f∈F 1n∑i=1nεi f(xi)],(24.10.2)\widehat{\mathfrak R}_S(\mathcal F) = \mathbb{E}_{\boldsymbol\varepsilon}\!\left[\, \sup_{f\in\mathcal F}\ \frac1n \sum_{i=1}^n \varepsilon_i\, f(\mathbf x_i) \right], \tag{24.10.2}

and its Rademacher complexity Rn(F)=ES[R^S(F)]\mathfrak R_n(\mathcal F)=\mathbb{E}_S[\widehat{\mathfrak R}_S(\mathcal F)] is the average of this quantity over random samples of size nn.

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 f∈Ff\in\mathcal F takes values in [−1,1][-1,1], then every correlation is at most 11, and the class of all functions into [−1,1][-1,1] achieves 11 on distinct points by setting f(xi)=εif(\mathbf x_i)=\varepsilon_i for every sign pattern. For a class taking values in [0,1][0,1], the maximum possible complexity is 12\tfrac12: the best choice sets f(xi)=1f(\mathbf x_i)=1 wherever εi=+1\varepsilon_i=+1 and 00 elsewhere, scoring the fraction of plus signs, which averages to 12\tfrac12. 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 11, and can be larger still.

To get a feel for the numbers, consider the simplest nontrivial class: the two constant functions {+1,−1}\{+1,-1\}. Its best correlation with a sign vector is max⁡(εˉ,−εˉ)=∣εˉ∣\max(\bar\varepsilon,-\bar\varepsilon)=|\bar\varepsilon|, where εˉ\bar\varepsilon is the sample average of the signs. For n=2n=2, the four equally likely patterns (+,+),(+,−),(−,+),(−,−)(+,+),(+,-),(-,+),(-,-) give ∣εˉ∣=1,0,0,1|\bar\varepsilon|=1,0,0,1, so R^S=12\widehat{\mathfrak R}_S=\tfrac12. For n=4n=4, the sum of the signs is ±4\pm4 with probability 216\tfrac2{16}, ±2\pm2 with probability 816\tfrac8{16}, and 00 otherwise, giving R^S=38\widehat{\mathfrak R}_S=\tfrac38. For large nn, εˉ\bar\varepsilon is approximately normal with mean 00 and variance 1/n1/n, so R^S≈2/(πn)\widehat{\mathfrak R}_S\approx\sqrt{2/(\pi n)}; at n=100n=100, the exact value is 0.07960.0796 compared with 0.07980.0798 from the normal approximation. Even a class with just two functions correlates with noise at rate 1/n1/\sqrt n, simply because the average of nn random signs fluctuates at that scale. By contrast, a singleton class {f}\{f\} has complexity 00: with nothing to choose from, E[1n∑iεif(xi)]=0\mathbb{E}[\frac1n\sum_i\varepsilon_if(\mathbf x_i)]=0.

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 nn. We prove this shortly in Section 24.10.2.3.

Figure 24.10.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 +1+1 and hollow dots −1-1. The best correlation is achieved by the unit weight vector w∗\mathbf w^* aligned with the signed sum s=∑iεixi\mathbf s=\sum_i\varepsilon_i\mathbf x_i, and equals ∥s∥/n=0.27\|\mathbf s\|/n=0.27. (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 Br/n=0.354Br/\sqrt n=0.354 proved in the text.

A finite class taking values in [−1,1][-1,1] satisfies Massart's lemma, R^S(F)≤2log⁡∣F∣/n\widehat{\mathfrak R}_S(\mathcal F)\le\sqrt{2\log|\mathcal F|/n} (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 F\mathcal F contains the models we fit, whereas the quantities whose averages we compare are the losses. We therefore define the loss class

G={(x,y)↦ℓ(f(x),y):f∈F},\mathcal G=\bigl\{(\mathbf x,y)\mapsto\ell(f(\mathbf x),y):f\in\mathcal F\bigr\},

whose functions take values in [0,1][0,1]. Writing z=(x,y)z=(\mathbf x,y) for a labeled example, let R(g)=E[g(z)]R(g)=\mathbb{E}[g(z)] and R^S(g)=1n∑ig(zi)\hat R_S(g)=\frac1n\sum_ig(z_i) for g∈Gg\in\mathcal G. 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 S=(z1,…,zn)S=(z_1,\ldots,z_n) be an i.i.d. sample and let G\mathcal G be a class of functions taking values in [0,1][0,1]. Then with probability at least 1−δ1-\delta,

R(g)≤R^S(g)+2 Rn(G)+log⁡(1/δ)2nsimultaneously for every g∈G.(24.10.3)R(g) \le \hat R_S(g) + 2\,\mathfrak R_n(\mathcal G) + \sqrt{\frac{\log(1/\delta)}{2n}} \qquad\textrm{simultaneously for every } g\in\mathcal G . \tag{24.10.3}

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, ES[sup⁡g(R(g)−R^S(g))]≤2Rn(G)\mathbb{E}_S\bigl[\sup_g(R(g)-\hat R_S(g))\bigr]\le2\mathfrak R_n(\mathcal G), in three steps; the high-probability statement follows from concentration.

I. Ghost sample. Introduce an independent copy S′=(z1′,…,zn′)S'=(z'_1,\ldots,z'_n) of the sample SS, which serves purely as an analytical device inside the proof. Because R(g)=ES′[R^S′(g)]R(g)=\mathbb{E}_{S'}[\hat R_{S'}(g)], and because the supremum of an expectation is always at most the expectation of the supremum, we obtain

ES[sup⁡g∈G(R(g)−R^S(g))]≤ES,S′[sup⁡g∈G 1n∑i=1n(g(zi′)−g(zi))].(24.10.4)\mathbb{E}_S\Bigl[\sup_{g\in\mathcal G}\bigl(R(g)-\hat R_S(g)\bigr)\Bigr] \le \mathbb{E}_{S,S'}\Bigl[\sup_{g\in\mathcal G}\ \frac1n\sum_{i=1}^n \bigl(g(z'_i)-g(z_i)\bigr)\Bigr]. \tag{24.10.4}

The unknown population risk has been replaced by the empirical risk on a fresh sample.

II. Sign swap. Swapping ziz_i with zi′z'_i leaves the joint distribution of (S,S′)(S,S') completely unchanged, since both points are independent draws from the same distribution. Yet that swap negates the ii-th difference g(zi′)−g(zi)g(z'_i)-g(z_i) for every g∈Gg\in\mathcal G simultaneously. Consequently, for any fixed choice of signs ε1,…,εn∈{−1,+1}\varepsilon_1,\ldots,\varepsilon_n\in\{-1,+1\}, multiplying the ii-th difference by εi\varepsilon_i does not change the right-hand side of (24.10.4). Averaging over random signs leaves it unchanged as well:

ES,S′[sup⁡g 1n∑i(g(zi′)−g(zi))]=ES,S′,ε[sup⁡g 1n∑iεi(g(zi′)−g(zi))].\mathbb{E}_{S,S'}\Bigl[\sup_{g}\ \frac1n\sum_i\bigl(g(z'_i)-g(z_i)\bigr)\Bigr] = \mathbb{E}_{S,S',\boldsymbol\varepsilon}\Bigl[\sup_{g}\ \frac1n\sum_i \varepsilon_i\bigl(g(z'_i)-g(z_i)\bigr)\Bigr].

III. Split. Since the supremum of a sum is at most the sum of the suprema, the right-hand side is bounded above by

ES′,ε[sup⁡g 1n∑iεi g(zi′)]+ES,ε[sup⁡g 1n∑i(−εi) g(zi)]=2 Rn(G),\mathbb{E}_{S',\boldsymbol\varepsilon}\Bigl[\sup_{g}\ \frac1n\sum_i \varepsilon_i\,g(z'_i)\Bigr] + \mathbb{E}_{S,\boldsymbol\varepsilon}\Bigl[\sup_{g}\ \frac1n\sum_i (-\varepsilon_i)\,g(z_i)\Bigr] = 2\,\mathfrak R_n(\mathcal G),

because −ε-\boldsymbol\varepsilon has the same distribution as ε\boldsymbol\varepsilon, making both expectations equal to Rn(G)\mathfrak R_n(\mathcal G). This split is where the factor of 22 comes from.

To pass from the expectation to a high-probability bound, define Φ(S)=sup⁡g(R(g)−R^S(g))\Phi(S)=\sup_g(R(g)-\hat R_S(g)). Replacing a single sample point ziz_i changes each empirical risk R^S(g)\hat R_S(g) by at most 1/n1/n (since gg takes values in [0,1][0,1]), and therefore changes the supremum Φ(S)\Phi(S) by at most 1/n1/n. 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 P(Φ−EΦ≥t)≤e−2nt2P(\Phi-\mathbb{E}\Phi\ge t)\le e^{-2nt^2} (exercise 1). Setting the right-hand side to δ\delta and combining with EΦ≤2Rn(G)\mathbb{E}\Phi\le2\mathfrak R_n(\mathcal G) yields (24.10.3). ■\blacksquare

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 Rn(G)\mathfrak R_n(\mathcal G), whereas on a real dataset we can only evaluate the empirical complexity R^S(G)\widehat{\mathfrak R}_S(\mathcal G) on the sample at hand. Because changing one sample point also moves R^S(G)\widehat{\mathfrak R}_S(\mathcal G) by at most 1/n1/n, a second application of McDiarmid's inequality lets us substitute R^S(G)\widehat{\mathfrak R}_S(\mathcal G) for Rn(G)\mathfrak R_n(\mathcal G) in (24.10.3) at the cost of widening the confidence term to 3log⁡(2/δ)/(2n)3\sqrt{\log(2/\delta)/(2n)}. Our numerical checks below use this empirical form.

It is always worth checking a theorem at its extremes. For a singleton class, Rn=0\mathfrak R_n=0 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 22log⁡2000/n=0.0782\sqrt{2\log 2000/n}=0.078, compared with the union bound's entire half-width of 0.0240.024. 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 nn points bounds Rn\mathfrak R_n by a constant times dVClog⁡n/n\sqrt{d_{\mathrm{VC}}\log n/n} (Boucheron et al., 2005), where dVCd_{\mathrm{VC}} 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 [0,1][0,1] satisfies Rn(G)≤12\mathfrak R_n(\mathcal G)\le\tfrac12. When equality holds, the complexity term 2Rn(G)2\mathfrak R_n(\mathcal G) equals 11, and the bound becomes vacuous, allowing any risk up to 100%. For binary classifiers taking values in {−1,+1}\{-1,+1\} under the 0-1 loss g(x,y)=(1−yf(x))/2g(\mathbf x,y)=(1-yf(\mathbf x))/2, the loss complexity and predictor complexity stand in an exact factor-of-two ratio. Expanding the correlation gives ∑iεig(zi)=12∑iεi+12∑i(−εiyi)f(xi)\sum_i\varepsilon_ig(z_i)=\tfrac12\sum_i\varepsilon_i+\tfrac12\sum_i(-\varepsilon_iy_i)f(\mathbf x_i). The first sum has mean zero and does not depend on ff, while for fixed labels yi∈{−1,+1}y_i\in\{-1,+1\}, the products −εiyi-\varepsilon_iy_i are again independent fair random signs. Taking the supremum and expectation yields

R^S(G)=12 R^S(F).\widehat{\mathfrak R}_S(\mathcal G)=\tfrac12\,\widehat{\mathfrak R}_S(\mathcal F).

Therefore, if a binary predictor class can fit every sign pattern on the sample, we have R^S(F)=1\widehat{\mathfrak R}_S(\mathcal F)=1, twice the loss complexity is 11, 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 F={x↦⟨w,x⟩:∥w∥2≤B}\mathcal F=\{\mathbf x\mapsto\langle\mathbf w,\mathbf x\rangle : \|\mathbf w\|_2\le B\} and suppose every sample input satisfies ∥xi∥2≤r\|\mathbf x_i\|_2\le r. Then

R^S(F)=Bn Eε∥∑i=1nεixi∥≤B rn.(24.10.5)\widehat{\mathfrak R}_S(\mathcal F) = \frac Bn\,\mathbb{E}_{\boldsymbol\varepsilon}\Bigl\|\sum_{i=1}^n\varepsilon_i\mathbf x_i\Bigr\| \le \frac{B\,r}{\sqrt n}. \tag{24.10.5}

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 w\mathbf w of length BB pointing in the direction of the signed sum:

sup⁡∥w∥≤B 1n∑i=1nεi⟨w,xi⟩=sup⁡∥w∥≤B 1n⟨w, ∑iεixi⟩=Bn ∥∑i=1nεixi∥.\sup_{\|\mathbf w\|\le B}\ \frac1n\sum_{i=1}^n \varepsilon_i \langle\mathbf w,\mathbf x_i\rangle = \sup_{\|\mathbf w\|\le B}\ \frac1n \Bigl\langle\mathbf w,\ \sum_i \varepsilon_i\mathbf x_i\Bigr\rangle = \frac Bn\,\Bigl\|\sum_{i=1}^n \varepsilon_i\mathbf x_i\Bigr\| .

Taking the expectation over ε\boldsymbol\varepsilon yields the equality in the proposition. To obtain the upper bound, invoke the concavity of the square root (E∥⋅∥≤E∥⋅∥2\mathbb{E}\|\cdot\|\le\sqrt{\mathbb{E}\|\cdot\|^2}) and expand the squared norm:

Eε∥∑iεixi∥≤∑i,jE[εiεj] ⟨xi,xj⟩=∑i∥xi∥2≤rn.\mathbb{E}_{\boldsymbol\varepsilon}\Bigl\|\sum_i\varepsilon_i\mathbf x_i\Bigr\| \le \sqrt{\sum_{i,j} \mathbb{E}[\varepsilon_i\varepsilon_j]\, \langle\mathbf x_i,\mathbf x_j\rangle} = \sqrt{\sum_i \|\mathbf x_i\|^2} \le r\sqrt n .

All cross terms vanish because independent fair signs satisfy E[εiεj]=0\mathbb{E}[\varepsilon_i\varepsilon_j]=0 for i≠ji\ne j. Multiplying by B/nB/n gives Br/nBr/\sqrt n. ■\blacksquare

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 E∥∑iεixi∥2=∑i∥xi∥2\mathbb{E}\|\sum_i\varepsilon_i\mathbf x_i\|^2=\sum_i\|\mathbf x_i\|^2 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% (0.3160.316 versus 0.3540.354). In two dimensions, a signed sum of many well-spread unit vectors behaves like a two-dimensional Gaussian vector, whose mean length is π/2≈0.89\sqrt\pi/2\approx0.89 times its root-mean-square length, so the slack stays near 11% regardless of nn. 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 dd does not appear at all. It enters only indirectly through BB and rr. 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 ∥w∥\|\mathbf w\| 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 ℓ1\ell_1 norm at most B1B_1 and whose hidden weight vectors have ℓ2\ell_2 norm at most B2B_2 has Rademacher complexity at most 2B1B2r/n2B_1B_2r/\sqrt n, regardless of its width (exercise 8).

A careful reader may raise a natural objection: the proposition requires fixing the radius BB 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 Bj=2jB_j=2^j with failure probability δj=δ/(j(j+1))\delta_j=\delta/(j(j+1)) (which sum to δ\delta), and evaluate the bound at the smallest BjB_j containing the fitted weight vector. For ∥w∥>1\|\mathbf w\|>1, this costs at most a factor of 22 in the complexity term and adds a mild log⁡log⁡∥w∥/n\sqrt{\log\log\|\mathbf w\|/n} 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 G\mathcal G, whereas our proposition bounded the predictor class F\mathcal F. A Lipschitz loss bridges the two.

Lemma (contraction) (Boucheron et al., 2013). Let ϕ1,…,ϕn:R→R\phi_1,\ldots,\phi_n:\mathbb{R}\to\mathbb{R} each be LL-Lipschitz. Then for any function class F\mathcal F and points x1,…,xn\mathbf x_1,\ldots,\mathbf x_n,

Eε[sup⁡f∈F∑i=1nεi ϕi(f(xi))]≤L Eε[sup⁡f∈F∑i=1nεi f(xi)].(24.10.6)\mathbb{E}_{\boldsymbol\varepsilon}\Bigl[\sup_{f\in\mathcal F}\sum_{i=1}^n \varepsilon_i\,\phi_i\bigl(f(\mathbf x_i)\bigr)\Bigr] \le L\,\mathbb{E}_{\boldsymbol\varepsilon}\Bigl[\sup_{f\in\mathcal F} \sum_{i=1}^n\varepsilon_i\,f(\mathbf x_i)\Bigr]. \tag{24.10.6}

In plain terms, composing a function class with transformations that stretch distances by at most LL can multiply its Rademacher complexity by at most LL. Allowing each ϕi\phi_i to be different is precisely what a supervised loss requires: at example ii, ϕi\phi_i is the map u↦ℓ(u,yi)u\mapsto\ell(u,y_i) with the label yiy_i held fixed. No centering condition is needed, because adding a constant cc to ϕi\phi_i shifts the sum by c εic\,\varepsilon_i, which has expectation zero. We state the contraction lemma without proof.

The uniform convergence theorem also requires losses bounded in [0,1][0,1]. Common training losses such as hinge and logistic loss are unbounded: on our norm-bounded linear class they can reach roughly 1+Br1+Br, 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 u=yf(x)u=yf(\mathbf x),

ϕγ(u)=min⁡{1,max⁡{0, 1−u/γ}}.\phi_\gamma(u)=\min\bigl\{1,\max\{0,\,1-u/\gamma\}\bigr\}.

The ramp loss equals 11 on a mistake (u≤0u\le0), drops to 00 once a prediction is correct by at least the margin γ\gamma (u≥γu\ge\gamma), and interpolates linearly in between. It upper-bounds the 0-1 loss everywhere and is (1/γ)(1/\gamma)-Lipschitz, as Figure 24.10.4 shows.

Figure 24.10.4:

The ramp loss ϕγ\phi_\gamma (blue) as a function of the margin u=yf(x)u=yf(\mathbf{x}), together with the 0-1 loss 1{u≤0}\mathbf{1}\{u\le0\} (dashed). The two agree except for 0<u<γ0\lt u\lt \gamma (shaded), where a prediction is correct by less than the margin and the ramp descends with slope −1/γ-1/\gamma.

Write R^γ(w)=1n∑iϕγ(yi⟨w,xi⟩)\hat R_\gamma(\mathbf w)=\frac1n\sum_i\phi_\gamma(y_i\langle\mathbf w,\mathbf x_i\rangle) for the empirical ramp loss on the sample. When every input satisfies ∥x∥≤r\|\mathbf x\|\le r, combining the contraction lemma with our linear-class proposition bounds the loss-class complexity by Br/(γn)Br/(\gamma\sqrt n). Plugging this into (24.10.3) yields a margin bound: with probability at least 1−δ1-\delta, simultaneously for every w\mathbf w with ∥w∥≤B\|\mathbf w\|\le B,

P(y⟨w,x⟩≤0)≤R^γ(w)+2Brγn+log⁡(1/δ)2n.(24.10.7)P\bigl(y\langle\mathbf w,\mathbf x\rangle\le0\bigr) \le \hat R_\gamma(\mathbf w) + \frac{2Br}{\gamma\sqrt n} + \sqrt{\frac{\log(1/\delta)}{2n}} . \tag{24.10.7}

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 Br/γ=10Br/\gamma=10, n=50,000n=50{,}000, and δ=0.05\delta=0.05 (choosing the ratio rather than measuring it on a specific dataset). The complexity term is 0.0890.089 and the confidence term is 0.0050.005, totaling 0.0950.095. Thus, with B=10γ/rB=10\gamma/r fixed in advance, any linear classifier in the class that separates its training set with margin γ\gamma is guaranteed, with 95% confidence, to have a true error rate below 9.5%9.5\%. By contrast, forcing a linear model to fit random labels with margin γ\gamma drives Br/γBr/\gamma upward: past Br/γ≈10.6Br/\gamma\approx10.6 the two penalty terms exceed 0.10.1, and near Br/γ≈110Br/\gamma\approx110 the complexity term alone reaches 11, 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 d=2d=2, 2020, and 1,0001{,}000 dimensions. Our slack analysis predicts an estimate roughly 11% below the bound Br/n=1/50Br/\sqrt n=1/\sqrt{50} 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 0.1250.125 in the plane and between 0.1390.139 and 0.1410.141 in 20 and 1,000 dimensions, right against the bound of 0.1410.141, 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 p=2np=2n standard Gaussian features, where the feature matrix Φ∈Rn×p\boldsymbol\Phi\in\mathbb{R}^{n\times p} holds the feature vectors of the nn points as rows. Using the pseudoinverse from Section 21.5.3.1, the solution w=Φ+ε\mathbf w=\boldsymbol\Phi^+\boldsymbol\varepsilon returns the minimum-norm interpolant for every sign vector ε\boldsymbol\varepsilon, achieving a correlation of 11 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 R^S≥1\widehat{\mathfrak R}_S\ge1, while (24.10.5) bounds it by Br/nBr/\sqrt n, so any ball containing all the interpolants must satisfy Br/n≥1Br/\sqrt n\ge1. 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 n/(p−n−1)\sqrt{n/(p-n-1)} (derived in exercise 4), and evaluate Br/nBr/\sqrt n 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 11, and the rows of Φ\boldsymbol\Phi have average length near p=10\sqrt p=10, placing a typical fit at ∥w∥r/n≈1.4\|\mathbf w\|r/\sqrt n\approx1.4. Across 2,000 sign patterns, the largest weight norm falls between 1.31.3 and 1.81.8 and the longest row between 1111 and 12.512.5, so the ball enclosing all 2,000 fits has Br/nBr/\sqrt n between 22 and 33. Interpolating pure noise therefore requires a norm only 1.5 to 3 times the theoretical floor: the linear-class bound Br/nBr/\sqrt n 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 ε\boldsymbol\varepsilon finds a function matching them at nearly every point, the supremum in (24.10.2) is close to 11 for that ε\boldsymbol\varepsilon; if this happens for typical sign vectors, the Rademacher complexity itself is close to 11. 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 11, 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 hh of a network whose hidden layer remained frozen at its random initialization. The test error spiked at h=nh=n, the exact threshold where interpolation first became possible and the smallest singular value of the hidden representation collapsed, and then descended again as hh 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 ϕ(x)=ReLU(Vx)\boldsymbol\phi(\mathbf x)=\mathrm{ReLU}(\mathbf V\mathbf x) with a frozen random matrix V\mathbf V, known as a random-features model (Rahimi and Recht, 2007), and we fit only the linear output head w\mathbf w. 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 p=np=n behaves so dramatically, let us write the solution in closed form. With pp features and nn training points, stack the training feature vectors as the rows of Φ∈Rn×p\boldsymbol\Phi\in\mathbb{R}^{n\times p}, and fit w=Φ+y\mathbf w=\boldsymbol\Phi^+\mathbf y. Below p=np=n, this is ordinary least squares; above p=np=n, 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, Φ⊤(Φw−y)\boldsymbol\Phi^\top(\boldsymbol\Phi\mathbf w-\mathbf y), is a combination of the training feature vectors, so gradient descent started at w=0\mathbf w=\mathbf 0 never leaves the row space of Φ\boldsymbol\Phi. The only interpolant in that row space is Φ+y\boldsymbol\Phi^+\mathbf y, 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 Φ\boldsymbol\Phi has full rank q=min⁡(n,p)q=\min(n,p) and singular value decomposition Φ=∑i=1qσiuivi⊤\boldsymbol\Phi=\sum_{i=1}^q\sigma_i\mathbf u_i\mathbf v_i^\top, with σ1≥⋯≥σq>0\sigma_1\ge\cdots\ge\sigma_q>0. Then the pseudoinverse solution is

w=Φ+y=∑i=1q⟨ui,y⟩σi vi.(24.10.8)\mathbf w=\boldsymbol\Phi^+\mathbf y=\sum_{i=1}^{q} \frac{\langle\mathbf u_i,\mathbf y\rangle}{\sigma_i}\,\mathbf v_i . \tag{24.10.8}

Each component of y\mathbf y along a left singular vector ui\mathbf u_i is divided by its singular value σi\sigma_i, so the smallest singular value σmin⁡=σq\sigma_{\min}=\sigma_q acts as the strongest amplifier. Whatever component of y\mathbf y falls along uq\mathbf u_q enters w\mathbf w magnified by 1/σmin⁡1/\sigma_{\min}, and this amplification hits both label noise and the part of the true target that the features approximate poorly.

When p<np\lt n, the fitted predictions Φw\boldsymbol\Phi\mathbf w simply project y\mathbf y onto the pp-dimensional span of the ui\mathbf u_i, leaving the remainder as training residual. At p=np=n, however, those nn directions span all of Rn\mathbb{R}^n: 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 vq\mathbf v_q. Adding features beyond p=np=n gives the matrix extra room to span Rn\mathbb{R}^n, and σmin⁡\sigma_{\min} climbs back up.

Past the threshold, the solution norm can only decrease as we add features, provided the feature sets are nested (the (p+1)(p+1)-feature model keeps all pp 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 pp-feature interpolant into a valid (p+1)(p+1)-feature interpolant of identical norm, so the new minimum norm can be no larger. Notice that this monotonicity relies on exact interpolation. Below p=np=n, the least-squares fit does not interpolate, and its norm actually grows with pp: in the sweep below, it climbs from roughly 0.50.5 at p=2p=2 to nearly 22 at p=15p=15.

Our linear-class bound suggests a natural quantity to monitor along the sweep: the capacity product ∥w∥⋅max⁡i∥ϕ(xi)∥/n\|\mathbf w\|\cdot\max_i\|\boldsymbol\phi(\mathbf x_i)\|/\sqrt n, which corresponds to Br/nBr/\sqrt n 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 p\sqrt p while ∥w∥\|\mathbf w\| 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 n=40n=40 training points from a linear teacher y=⟨β,x⟩y=\langle\boldsymbol\beta,\mathbf x\rangle in d=15d=15 dimensions, with ∥β∥=1\|\boldsymbol\beta\|=1 and Gaussian label noise of standard deviation 0.10.1. We construct nested ReLU random features and fit the linear head via pinv, giving least squares below p=40p=40 and the minimum-norm interpolant above it. We sweep pp from 22 to 400400, including p=39p=39, 4040, and 4141 so the threshold peak is sharply resolved. At each pp, we log the test MSE, training MSE, ∥w∥\|\mathbf w\|, σmin⁡\sigma_{\min}, 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 11 at p=2p=2 to about 0.650.65–0.850.85 near p=15p=15, and then climbs again as pp approaches 4040, 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 11 (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 0.01⋅15/(40−15−1)≈0.0060.01\cdot15/(40-15-1)\approx0.006 (the noise variance times d/(n−d−1)d/(n-d-1) for d=15d=15), 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 10−310^{-3} at p=38p=38 to roughly 10−2810^{-28}, exact interpolation up to floating-point precision. Simultaneously, the smallest singular value drops to around 0.010.01–0.040.04, several times smaller than at p=38p=38 or p=42p=42. Because (24.10.8) divides by σmin⁡\sigma_{\min}, the solution explodes: ∥w∥\|\mathbf w\| jumps to between 1010 and 3030, and test MSE spikes to between 1010 and 7070, 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 E[1/σmin⁡2]=∞\mathbb{E}[1/\sigma_{\min}^2]=\infty; 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 2.82.8 at p=400p=400. As the padding argument guarantees, ∥w∥\|\mathbf w\| declines monotonically in every trial (not just in the medians), reaching roughly 0.40.4. Test MSE follows it downward, to about 0.20.2 at p=80p=80 and 0.040.04–0.070.07 at p=400p=400. Meanwhile, one column goes completely silent: training error sits at zero (up to floating point) everywhere past p=40p=40, so no criterion based on training loss can tell p=42p=42 apart from p=400p=400, even though their test errors differ by more than an order of magnitude. The solution norm, σmin⁡\sigma_{\min}, 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 p=40p=40 and drops back to roughly 1.21.2–1.31.3 at p=400p=400. 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 BB 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 p=40p=40, 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 uq\mathbf u_q is what σmin⁡\sigma_{\min} 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 p=400p=400, 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 y=y0+ξ\mathbf y=\mathbf y_0+\boldsymbol\xi, where y0\mathbf y_0 are the noise-free labels and ξ\boldsymbol\xi is independent noise with variance σξ2=0.01\sigma_\xi^2=0.01 per example. By linearity of the pseudoinverse, w=Φ+y0+Φ+ξ\mathbf w=\boldsymbol\Phi^+\mathbf y_0+\boldsymbol\Phi^+\boldsymbol\xi, so the test predictions split into ΦteΦ+y0+ΦteΦ+ξ\boldsymbol\Phi_{\mathrm{te}}\boldsymbol\Phi^+\mathbf y_0+\boldsymbol\Phi_{\mathrm{te}}\boldsymbol\Phi^+\boldsymbol\xi. Because ξ\boldsymbol\xi has mean zero, the cross term vanishes in expectation, leaving an exact decomposition of the expected test MSE over nten_{\mathrm{te}} test points:

Eξ[test error]=1nte∥ΦteΦ+y0−yte∥2⏟clean part+σξ2nte∥ΦteΦ+∥F2⏟noise part.\begin{aligned} \mathbb{E}_{\boldsymbol\xi}\bigl[\textrm{test error}\bigr] &= \underbrace{\frac{1}{n_{\mathrm{te}}}\bigl\|\boldsymbol\Phi_{\mathrm{te}}\boldsymbol\Phi^+\mathbf y_0-\mathbf y_{\mathrm{te}}\bigr\|^2}_{\textrm{clean part}} \\ &\quad + \underbrace{\frac{\sigma_\xi^2}{n_{\mathrm{te}}}\bigl\|\boldsymbol\Phi_{\mathrm{te}}\boldsymbol\Phi^+\bigr\|_F^2}_{\textrm{noise part}} . \end{aligned}

The clean and noise columns of our table print these two terms. At p=40p=40, the noise part is roughly 11 to 44 (a hundred times or more the label-noise variance of 0.010.01), and the clean part is larger still. By p=42p=42 the noise part drops to a few tenths, at p=80p=80 to about 0.020.02, and at p=400p=400 to just under 0.010.01. Over the same stretch, the clean part falls from roughly 8–60 at the peak to about 0.050.05 at p=400p=400, 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 p=40p=40, become nearly harmless at p=400p=400? By (24.10.8), a noise component along ui\mathbf u_i enters the weights scaled by 1/σi1/\sigma_i along vi\mathbf v_i, and shifts a test prediction in proportion to the test feature's component along vi\mathbf v_i. Using ∥ΦteΦ+∥F2=∑i∥Φtevi∥2/σi2\|\boldsymbol\Phi_{\mathrm{te}}\boldsymbol\Phi^+\|_F^2=\sum_i\|\boldsymbol\Phi_{\mathrm{te}}\mathbf v_i\|^2/\sigma_i^2 together with σi2=∥Φvi∥2\sigma_i^2=\|\boldsymbol\Phi\mathbf v_i\|^2, the noise part for p≥np\ge n takes the illuminating form

σξ2⋅1n∑i=1n∥Φtevi∥2/nte∥Φvi∥2/n,\sigma_\xi^2\cdot\frac1n\sum_{i=1}^{n} \frac{\|\boldsymbol\Phi_{\mathrm{te}}\mathbf v_i\|^2/n_{\mathrm{te}}} {\|\boldsymbol\Phi\mathbf v_i\|^2/n} ,

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 vi\mathbf v_i. A tiny singular value σi\sigma_i only causes trouble when test inputs carry substantial energy in that same direction. At p=np=n, a tiny σmin⁡\sigma_{\min} is an accident of the forty training points: along vq\mathbf v_q, the test features are typically thousands of times larger in mean square than the training features. At p=400p=400, by contrast, a small σi\sigma_i 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 vq\mathbf v_q) is only about 22, and ratio (averaged over all directions) sits just below 11, 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 p=400p=400, 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 F\mathcal F, Hoeffding's inequality and the union bound achieve this at a cost of log⁡∣F∣/(2t2)\log|\mathcal F|/(2t^2) additional examples at tolerance tt. 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 (∥w∥2≤B\|\mathbf w\|_2\le B, ∥xi∥2≤r\|\mathbf x_i\|_2\le r), this complexity is at most Br/nBr/\sqrt n, 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 σmin⁡\sigma_{\min} 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#

  1. McDiarmid's inequality. ● The inequality of McDiarmid (1989) extends Hoeffding's from sums to functions with bounded differences. Suppose that changing only the ii-th argument of g(x1,…,xn)g(x_1,\ldots,x_n) moves its value by at most cic_i, and that X1,…,XnX_1,\ldots,X_n are independent. Then
P(g(X1,…,Xn)−E[g(X1,…,Xn)]≥t)≤exp⁡(−2t2∑i=1nci2),(24.10.9)P\bigl(g(X_1,\ldots,X_n)-\mathbb{E}[g(X_1,\ldots,X_n)]\ge t\bigr)\le\exp\left(-\frac{2t^2}{\sum_{i=1}^n c_i^2}\right), \tag{24.10.9}

and the same bound holds for the lower tail. Take this statement on faith; its proof uses martingales.

  1. Recover Hoeffding's inequality for an average of independent terms Xi∈[ai,bi]X_i\in[a_i,b_i] from it.
  2. Let Φ(S)=sup⁡g∈G(R(g)−R^S(g))\Phi(S)=\sup_{g\in\mathcal G}\bigl(R(g)-\hat R_S(g)\bigr) for a loss class G\mathcal G with values in [0,1][0,1]. Show that Φ\Phi has bounded differences ci=1/nc_i=1/n. Combine McDiarmid's inequality with the symmetrization bound ES[Φ(S)]≤2Rn(G)\mathbb{E}_S[\Phi(S)]\le 2\mathfrak R_n(\mathcal G) of the text and derive (24.10.3).
  3. For data in [0,1][0,1], the sample mean has bounded differences 1/n1/n. Construct a sample of odd size nn in [0,1][0,1] in which changing one point moves the sample median by 11. 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?
  1. Massart's lemma and ℓ1\ell_1 balls. ● Massart's lemma for finite classes and the Rademacher complexity of ℓ1\ell_1-bounded linear classes rest on one bound for the expected maximum of sub-Gaussian variables.

    1. Let Z1,…,ZNZ_1,\ldots,Z_N be centered and sub-Gaussian with variance proxy σ2\sigma^2, that is, E[eλZj]≤eλ2σ2/2\mathbb{E}[e^{\lambda Z_j}]\le e^{\lambda^2\sigma^2/2} for all λ\lambda, but not necessarily independent. Show that E[max⁡jZj]≤σ2log⁡N\mathbb{E}[\max_j Z_j]\le\sigma\sqrt{2\log N} by bounding eλE[max⁡jZj]e^{\lambda \mathbb{E}[\max_j Z_j]} by ∑jE[eλZj]\sum_j \mathbb{E}[e^{\lambda Z_j}] and optimizing over λ>0\lambda>0. Deduce Massart's lemma, R^S(F)≤2log⁡∣F∣/n\widehat{\mathfrak R}_S(\mathcal F)\le\sqrt{2\log|\mathcal F|/n}, for a finite class with values in [−1,1][-1,1].
    2. Let F={x↦⟨w,x⟩:∥w∥1≤B}\mathcal F=\{\mathbf x\mapsto\langle\mathbf w,\mathbf x\rangle: \|\mathbf w\|_1\le B\} and ∥xi∥∞≤r\|\mathbf x_i\|_\infty\le r for all ii. Follow the proof of (24.10.5), with the duality sup⁡∥w∥1≤B⟨w,v⟩=B∥v∥∞\sup_{\|\mathbf w\|_1\le B}\langle\mathbf w,\mathbf v\rangle=B\|\mathbf v\|_\infty in place of Cauchy--Schwarz, and show that R^S(F)≤Br2log⁡(2d)/n\widehat{\mathfrak R}_S(\mathcal F)\le Br\sqrt{2\log(2d)/n}. Why does the dimension dd now enter, and why only logarithmically?
    3. Let the inputs lie in {−1,+1}d\{-1,+1\}^d and let the target weight vector have kk nonzero entries, each equal to ±1\pm1. Compare the bound of (b) with (24.10.5), each with the smallest radius BB that contains the target. For which kk is the ℓ1\ell_1 bound smaller when d=104d=10^4?
  2. Margin bound. ● Let F={x↦⟨w,x⟩:∥w∥2≤B}\mathcal F=\{\mathbf x\mapsto\langle\mathbf w,\mathbf x\rangle:\|\mathbf w\|_2\le B\} with ∥x∥2≤r\|\mathbf x\|_2\le r, let the labels be y∈{−1,+1}y\in\{-1,+1\}, and let the ramp loss ϕγ(u)=min⁡{1,max⁡{0,1−u/γ}}\phi_\gamma(u)=\min\{1,\max\{0,1-u/\gamma\}\} with a fixed γ>0\gamma>0 act on the margin u=yf(x)u=yf(\mathbf x).

    1. Show that ϕγ(yf(x))\phi_\gamma(yf(\mathbf x)) is at least the 0-1 loss 1{yf(x)≤0}\mathbf 1\{yf(\mathbf x)\le 0\} and that ϕγ\phi_\gamma is (1/γ)(1/\gamma)-Lipschitz. Show that multiplying each prediction f(xi)f(\mathbf x_i) by a fixed label yiy_i leaves R^S(F)\widehat{\mathfrak R}_S(\mathcal F) unchanged.
    2. Combine (a), the contraction lemma (24.10.6), (24.10.3), and (24.10.5) into (24.10.7). For n=50,000n=50{,}000 and δ=0.05\delta=0.05, find the largest ratio Br/γBr/\gamma for which the complexity and confidence terms together stay below 0.10.1.
    3. The bound holds for a radius BB fixed before the data are drawn, whereas the norm of a trained weight vector is known only afterwards. Apply the bound with radius Bj=2jB_j=2^j and confidence δj=δ/(j(j+1))\delta_j=\delta/(j(j+1)) for every j≥1j\ge1, and take a union bound over jj. State the bound that holds for a weight vector with ∥w∥>1\|\mathbf w\|>1 chosen after seeing the data. Show that the freedom to choose the radius costs at most a factor 22 in the complexity term and an additional term of order log⁡log⁡∥w∥/n\sqrt{\log\log\|\mathbf w\|/n}.
  3. [code] Fitting random signs. ● The second cell of Section 24.10.2.4 fits 2,0002{,}000 sign vectors ε∈{−1,+1}n\boldsymbol\varepsilon\in\{-1,+1\}^n with w=Φ+ε\mathbf w=\boldsymbol\Phi^+\boldsymbol\varepsilon on p=2np=2n standard Gaussian features and measures the norms of the fits.

    1. Let p<np\lt n and let Φ\boldsymbol\Phi have full column rank. Show that the correlation 1n∑iεi(Φw)i\frac1n\sum_i\varepsilon_i(\boldsymbol\Phi\mathbf w)_i has expectation p/np/n over the signs. The matrix ΦΦ+\boldsymbol\Phi\boldsymbol\Phi^+ is a projection.
    2. Let p>np>n, let rr be the largest row norm of Φ\boldsymbol\Phi, and let BB be large enough that the class {∥w∥≤B}\{\|\mathbf w\|\le B\} contains an interpolant of every sign vector. Explain why Br/nBr/\sqrt n cannot then be smaller than 11. For a standard Gaussian Φ\boldsymbol\Phi with p>n+1p>n+1, E[(ΦΦ⊤)−1]=In/(p−n−1)\mathbb{E}[(\boldsymbol\Phi\boldsymbol\Phi^\top)^{-1}]=\mathbf I_n/(p-n-1). Use this identity to predict the typical ∥w∥\|\mathbf w\|, and the typical value of ∥w∥\|\mathbf w\| times a typical row norm of Φ\boldsymbol\Phi divided by n\sqrt n, as functions of pp and nn.
    3. Rerun the cell with n=50n=50 for p∈{10,25,45,55,100,400,1000}p\in\{10,25,45,55,100,400,1000\} (for p<np\lt n print the correlation instead of the norm) and compare with (a) and (b). What happens to the capacity value of (b) as p→∞p\to\infty, and why does the version with the largest row norm stay above 11?
  4. [code] Leaderboard attack. ●● A leaderboard reports the 0-1 loss of each submitted label vector on a holdout set of n=4,000n=4{,}000 examples with labels y∈{0,1}n\mathbf y\in\{0,1\}^n. The boosting attack of Blum and Hardt (2015) uses no knowledge of the task: submit kk uniformly random label vectors, keep those with reported loss at most 12\tfrac12, and submit their coordinatewise majority vote. On fresh data, the majority vote has loss 12\tfrac12.

    1. Implement the attack for uniformly random y\mathbf y and k∈{10,30,100,300,1000,3000}k\in\{10,30,100,300,1000,3000\}, and record the reported loss of the majority vote. Compare its distance from 12\tfrac12 with the deviation that (24.10.1) allows for a pre-registered pool of k+1k+1 models at δ=0.05\delta=0.05. From which kk on does the attack exceed this deviation, and which hypothesis of the proposition does it violate?
    2. Blum and Hardt (2015) prove that the reported loss is 12−Ω(k/n)\tfrac12-\Omega(\sqrt{k/n}) but do not give the constant. Derive it heuristically with Gaussian approximations: estimate the expected excess agreement with y\mathbf y of a kept vector, then the probability that the majority of about k/2k/2 such vectors is correct on one coordinate. Compare the constant with the measurements of (a).
    3. 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 η\eta, rounds it to a multiple of η\eta, and otherwise repeats the previous score. Against the Ladder, the attacker can only keep the vectors that lowered the released score. Implement both for η∈{0.005,0.01}\eta\in\{0.005,0.01\} and k∈{100,1000,3000}k\in\{100,1000,3000\}. How far below 12\tfrac12 does the majority vote now get, and how does this compare with the deviation of (a)?
  5. [code] The square case. ● Use the sweep of the double-descent experiment in Section 24.10.3.2.

    1. Show from the stored norms that the nesting monotonicity fails below the threshold, and explain why the padding argument does not apply there.
    2. At p=np=n, decompose w\mathbf w along (24.10.8). Report, as a median over trials, the coefficient ∣⟨un,y⟩∣/σmin⁡|\langle\mathbf u_n,\mathbf y\rangle|/\sigma_{\min} of the smallest singular direction next to ∥w∥\|\mathbf w\|. Which share of the norm does this one direction carry?
    3. Rerun the sweep with noise = 0. Then replace the teacher by a target y=⟨c,ϕ1:10(x)⟩y=\langle\mathbf c,\boldsymbol\phi_{1:10}(\mathbf x)\rangle that is an exact combination of the first ten features, with ∥c∥=1\|\mathbf c\|=1 and no noise. Describe the two curves. In each case, what does σmin⁡\sigma_{\min} divide? Why does the minimum-norm interpolant become worse as features are added when the target uses only ten of them?
    4. Add label noise of standard deviation 0.10.1 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?
  6. [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 x∼N(0,Σ)\mathbf x\sim\mathcal N(\mathbf 0,\boldsymbol\Sigma) with Σ=diag⁡(λ1,…,λp)\boldsymbol\Sigma=\operatorname{diag}(\lambda_1,\ldots,\lambda_p) and λ1≥λ2≥⋯\lambda_1\ge\lambda_2\ge\cdots, let y=⟨θ∗,x⟩+ξy=\langle\boldsymbol\theta^*,\mathbf x\rangle+\xi with ξ∼N(0,σ2)\xi\sim\mathcal N(0,\sigma^2), stack n<pn\lt p training inputs into X∈Rn×p\mathbf X\in\mathbb R^{n\times p}, and let θ^=X+y\hat{\boldsymbol\theta}=\mathbf X^+\mathbf y. The excess risk is (θ^−θ∗)⊤Σ(θ^−θ∗)(\hat{\boldsymbol\theta}-\boldsymbol\theta^*)^\top\boldsymbol\Sigma (\hat{\boldsymbol\theta}-\boldsymbol\theta^*).

    1. Show that its expectation over the noise is the sum of a bias term θ∗⊤(I−P)Σ(I−P)θ∗\boldsymbol\theta^{*\top}(\mathbf I-\mathbf P)\boldsymbol\Sigma (\mathbf I-\mathbf P)\boldsymbol\theta^*, where P=X+X\mathbf P=\mathbf X^+\mathbf X, and a variance term σ2tr⁡((X+)⊤ΣX+)\sigma^2\operatorname{tr}\bigl((\mathbf X^+)^\top\boldsymbol\Sigma \mathbf X^+\bigr). Implement both terms; no test set is needed.
    2. The paper's effective ranks are ρk=∑i>kλi/λk+1\rho_k=\sum_{i>k}\lambda_i/\lambda_{k+1} and ϱk=(∑i>kλi)2/∑i>kλi2\varrho_k=\bigl(\sum_{i>k}\lambda_i\bigr)^2/\sum_{i>k}\lambda_i^2. With k∗k^* the smallest kk such that ρk≥bn\rho_k\ge bn, the variance term is of order σ2(k∗/n+n/ϱk∗)\sigma^2(k^*/n+n/\varrho_{k^*}) up to constants; take b=1b=1. Use n=100n=100, σ=1\sigma=1, five strong directions with λi=1\lambda_i=1 that contain a unit-norm θ∗\boldsymbol\theta^*, and qq weak directions with λi=1/q\lambda_i=1/q each, for q∈{100,300,103,3⋅103,104}q\in\{100,300,10^3,3\cdot10^3,10^4\}. Compare the measured variance with σ2(k∗/n+n/ϱk∗)\sigma^2(k^*/n+n/\varrho_{k^*}). What happens at q=100q=100, and why?
    3. Repeat with power-law spectra λi=i−α\lambda_i=i^{-\alpha} truncated at p=40np=40n, for α∈{0.5,1,2}\alpha\in\{0.5,1,2\}, θ∗=e1\boldsymbol\theta^*=\mathbf e_1, and n∈{50,100,200,400}n\in\{50,100,200,400\}. For which spectra does the excess risk decrease with nn? For the others, does the bias or the variance fail, and how do ρ0/n\rho_0/n, k∗/nk^*/n, and n/ϱk∗n/\varrho_{k^*} show it?
  7. Norms, not widths: a two-layer network. ●● Let F1={x↦ReLU(⟨v,x⟩):∥v∥2≤B2}\mathcal F_1=\{\mathbf x\mapsto\mathrm{ReLU}(\langle\mathbf v,\mathbf x\rangle):\|\mathbf v\|_2\le B_2\} and F2={x↦∑j=1hwj ReLU(⟨vj,x⟩):∥w∥1≤B1, ∥vj∥2≤B2}\mathcal F_2=\{\mathbf x\mapsto\sum_{j=1}^hw_j\,\mathrm{ReLU}(\langle\mathbf v_j,\mathbf x\rangle):\|\mathbf w\|_1\le B_1,\ \|\mathbf v_j\|_2\le B_2\}, on points with ∥xi∥≤r\|\mathbf x_i\|\le r.

    1. Show that R^S(F1)≤B2r/n\widehat{\mathfrak R}_S(\mathcal F_1)\le B_2r/\sqrt n.
    2. Show that F2\mathcal F_2 is contained in B1B_1 times the convex hull of F1∪(−F1)\mathcal F_1\cup(-\mathcal F_1), and that taking the convex hull of a class does not change its empirical Rademacher complexity. Hint: ∑jwjfj=∥w∥1∑j∣wj∣∥w∥1(±fj)\sum_jw_jf_j=\|\mathbf w\|_1\sum_j\frac{|w_j|}{\|\mathbf w\|_1}(\pm f_j).
    3. Using 0∈F10\in\mathcal F_1, show that Eεsup⁡f∈F1∣∑iεif(xi)∣≤2n R^S(F1)\mathbb{E}_{\boldsymbol\varepsilon}\sup_{f\in\mathcal F_1}|\sum_i\varepsilon_if(\mathbf x_i)|\le2n\,\widehat{\mathfrak R}_S(\mathcal F_1), and conclude that R^S(F2)≤2B1B2r/n\widehat{\mathfrak R}_S(\mathcal F_2)\le2B_1B_2r/\sqrt n.
    4. The width hh 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?

Discussions