MDL1 — How Deep Learning Changed Statistical Learning Theory
Mysteries of Deep Learning, Iliad Intensive 2026
Classical learning theory suggests that a model with sufficient capacity to fit its training data exactly has no reason to generalize well on fresh data. Deep networks, however, can generalize well while being highly overparameterized and fitting their training data exactly. This workbook explores what these observations broke in learning theory, and what survives. It is the derivations workbook, so most sections end in exercises with worked solutions folded beneath them.
- 1. Keystone: vacuous bounds and double descent: random labels make class-wide bounds vacuous; past interpolation, test error falls again.
- 2. Reference cases: risk, least squares, bias–variance: the textbook quantities, computed exactly.
- 3. Theorems that seem to forbid learning: no free lunch, universal approximation, VC dimension.
- 4. Regularization: prior, constraint, filter, flatness: what weight decay, early stopping, dropout and flat minima do in linear models.
- 5. Interpolation without harm: kernels, the ridgeless limit, benign overfitting.
- 6. PAC-Bayes: a bound for the function you found, not the class.
- 7. Bayes and MLE generalization error: the sandwich, TIC, AIC, BIC; a fit versus the Bayes ensemble.
- 8. Gradient noise, curvature, and generalization measures: SGD is not a posterior sampler; which measures predict the gap.
- 9. The information bottleneck: did deep networks compress?
Exercise k.m part j is cited as k.m.j. Each exercise states the notation it uses.
1. Keystone: vacuous bounds and double descent
Two observations broke the textbook account of generalization:
- Standard networks fit uniformly random labels to zero training error (Zhang et al.), so any bound on generalization that depends only on the model class must be vacuous.
- As model size grows through the interpolation threshold (where training error first reaches zero), test error falls, rises, and falls again (Belkin et al.), so fitting the training data exactly is not by itself overfitting.
Every later section of this workbook is a response to one of these observations. The readings below give an overview of these observations. Readers should feel free to read them in as much depth as their interest and time permit, as guided by the marked importance and length.
Notation (used throughout the workbook): n samples, p parameters or features, \gamma=p/n; \sigma^2 is the label-noise variance, \tau^2 a Gaussian prior variance on the coefficients \beta, r^2=\|\beta\|^2, and \lambda the ridge penalty in \frac1n\|y-X\beta\|^2+\lambda\|\beta\|^2.
The paper that killed deep learning theory, Lawrence Chan (LessWrong, 2026)
A short account of Zhang et al. (2016), and why fitting random labels ended the programme of explaining generalization by the capacity of the model class.
The other paper that killed deep learning theory, Lawrence Chan (LessWrong, 2026)
On Nagarajan and Kolter (2019): the data-dependent norm and margin bounds proposed after Zhang et al. grow with the sample size, and uniform convergence provably cannot explain generalization in some overparametrized settings, even restricted to what gradient descent outputs.
Understanding deep learning requires rethinking generalization, Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, Oriol Vinyals (ICLR 2017)
Standard image classifiers trained by SGD reach zero training error on random labels and random pixels, with or without explicit regularization. Read §1–§2; §3 is short.
Reconciling modern machine-learning practice and the classical bias–variance trade-off, Mikhail Belkin, Daniel Hsu, Siyuan Ma, Soumik Mandal (PNAS, 2019)
Names double descent: test error peaks at the interpolation threshold and falls again as capacity grows, in random-feature models, small networks and tree ensembles. The figures carry the argument.
Surprises in high-dimensional ridgeless least squares interpolation, Trevor Hastie, Andrea Montanari, Saharon Rosset, Ryan J. Tibshirani (Annals of Statistics, 2022)
Exact asymptotics of minimum-norm interpolation and ridge as p/n → γ, the source of exercises 1.3–1.6. Read §1 and §3; §5 shows when the best γ can lie above 1, §8 does random features.
Maybe I was too harsh on deep learning theory (three days ago), Lawrence Chan (LessWrong, 2026)
A partial retraction: the signal-propagation (mean-field) and Tensor Programs line, which produced μP, counts as real cumulative theory, though it does not explain generalization.
Also: Nagarajan and Kolter, Uniform convergence may be unable to explain generalization in deep learning (NeurIPS 2019); Nakkiran et al., Deep double descent (2019), double descent in model size, training time and sample size for real networks.
Exercises: capacity bounds meet a real network
This exercise makes observation 1 above quantitative. Classical generalization bounds depend only on the function class, the sample size n and a confidence level, and so in particular must hold for every data distribution. Zhang et al. trained standard architectures on CIFAR-10 images with labels drawn uniformly at random. Despite the mislabeling, the networks still reached zero training error, while every classifier has expected test error 0.9 on such data (there are ten classes, and the labels carry no information about the image). Because the functions reachable by training include ones with a test-train gap of 0.9, a bound that holds for every distribution must allow that gap on the real labels too, where the same networks are known to generalize well. Classical generalization bounds are therefore vacuous for these networks. Nagarajan and Kolter showed that shrinking the function class does not help: they construct data distributions on which gradient descent generalizes well, yet any uniform bound over only the functions gradient descent returns on samples from that distribution is still vacuous, even though such a bound may depend on both the distribution and the training procedure.
1.1. Plug in a real network. Use the 0–1 loss, \ell(h(x),y)=\mathbf 1[h(x)\ne y], which is 1 on a mistake and 0 otherwise. The population risk of a classifier h is its expected loss on a fresh example drawn from the data distribution, R(h)=\mathbb E[\ell(h(x),y)]; for the 0–1 loss this is its test error. The empirical risk \hat R_n(h) is its average loss over the n training examples, its training error. The difference R(h)-\hat R_n(h) is the generalization gap, and it is what a generalization bound controls. Call the set of classifiers the learner may choose from the hypothesis class \mathcal H. The simplest of the classical bounds applies when \mathcal H is finite: with probability at least 1-\delta over the draw of the training set, every h\in\mathcal H at once satisfies |R(h)-\hat R_n(h)|\le\sqrt{\ln(2|\mathcal H|/\delta)/(2n)}. “Every h at once” is what makes this a uniform bound; the bounds for infinite classes (§3) have the same form with \ln|\mathcal H| replaced by another measure of the size of the class. A bound is vacuous if it exceeds 1, the largest value the gap can take.
- For one fixed h, the training error is an average of n independent 0/1 variables with mean R(h), and Hoeffding’s inequality says that such an average is unlikely to be far from its mean: \Pr[|\hat R_n(h)-R(h)|>t]\le2e^{-2nt^2}. Derive the finite-class bound stated above from this and the fact that the probability of a union of events is at most the sum of their probabilities.
- A network with W=10^6 float32 weights is a finite class, since each weight takes at most 2^{32} values, so |\mathcal H|\le2^{32W}. Evaluate the bound for n=5\times10^4 (the size of the CIFAR-10 training set) and \delta=0.05. Then compare n with d\approx W\ln W, a general upper bound on the VC dimension of ReLU networks of fixed depth. §3 defines the VC dimension; for now, take it as the largest number of inputs the class can label in every possible way, and take as given that a VC bound on the gap is small only when n\gg d.
- Zhang et al. show that this kind of architecture, trained by SGD, fits CIFAR-10 images with uniformly random labels to zero training error. Let \mathcal H be the set of functions the architecture and SGD can produce, and write \mathrm{gap}(h)=R(h)-\hat R_n(h). Assume that this fitting succeeds with high probability on i.i.d. samples from a distribution whose labels are uniform and independent of the image, and whose inputs are distinct. Show that every bound of the form “for every data distribution P, with probability \ge1-\delta, all h\in\mathcal H have \mathrm{gap}(h)\le\epsilon(n,\delta)” must have \epsilon\ge0.9 (10 classes), up to sampling fluctuation.
Hint
For 3, the bound has to hold for every P. Choose one.
Solution
1. For a fixed h, \Pr[|\hat R_n(h)-R(h)|>t]\le2e^{-2nt^2}. The event that some h\in\mathcal H has a gap larger than t is the union over h of these events, so its probability is at most 2|\mathcal H|e^{-2nt^2}. Setting this equal to \delta and solving for t gives t=\sqrt{\ln(2|\mathcal H|/\delta)/(2n)}.
2. \ln|\mathcal H|\le32W\ln2\approx2.22\times10^7, so the bound is \sqrt{(2.22\times10^7+\ln 40)/10^5}\approx\sqrt{222}\approx14.9. The gap cannot exceed 1, so a bound of 14.9 says nothing. The VC scale W\ln W\approx1.4\times10^7 is far larger than n=5\times10^4, so a VC bound is vacuous too. (This scale is a generic upper bound; it does not prove that this architecture has so large a VC dimension. But if the true VC dimension is at least n, then the class can label some set of n inputs in every possible way, and the no-free-lunch argument of 3.1.1 applies: for inputs drawn uniformly from that set, a training sample of size n misses an expected fraction (1-1/n)^n\approx e^{-1} of them, and some labelling of the missed inputs makes any learner wrong on half of them, so the expected error is at least \tfrac12(1-1/n)^n\approx0.18.)
3. Take P' to be CIFAR-10 images with labels drawn uniformly from the 10 classes, independently of the image. By assumption SGD then reaches an h\in\mathcal H with \hat R_n(h)=0. The label of a fresh example is independent of its image, so any classifier is right with probability 1/10: R(h)=0.9, and \mathrm{gap}(h)=0.9 with high probability. A bound that depends only on \mathcal H, n and \delta must hold for P' in particular, so \epsilon(n,\delta)\ge0.9-o(1). The same bound then applies, and is vacuous, on the real labels as well. (Zhang et al.’s experiment is on one fixed image collection; it motivates the assumption that fitting succeeds on random draws, but does not prove it.) A vacuous bound is not wrong, but it cannot be the explanation. 1.2.1 asks which explanations survive.
1.2. Questions on Zhang et al.
- List the explanations of generalization that the random-labels experiment rules out, and those it leaves standing.
- The paper finds that the usual explicit regularizers help but are neither necessary nor sufficient for generalization. These are weight decay, which adds a penalty \lambda\|\theta\|^2 on the weights \theta to the training loss; dropout, which randomly zeroes units during training; and data augmentation, which trains on transformed copies of the images. The weight-decay penalty has three standard readings, each derived in §4. It is a Gaussian prior on the weights, so that minimizing the penalized loss finds the most probable weights given the data. It is a constraint that keeps the weights inside a ball of fixed radius, a smaller class to which classical bounds might apply. And it is a spectral filter: it shrinks the components of the weights along the directions that the data barely determine, which gradient descent stopped early also does. Which reading does the finding count against, and which survive?
Solution
1. Ruled out:
- any explanation in which the class of reachable functions is small enough for a bound that holds for every distribution to be tight. This covers the VC dimension, and also the Rademacher complexity, which measures how well functions in the class can fit random \pm1 labels on the training inputs: fitting random labels pushes it to its maximum, as the paper notes in §2.2;
- explicit regularization as the main cause, since the networks generalize nearly as well without it;
- “SGD cannot find memorizing solutions”, since it finds them, only a constant factor more slowly.
Not ruled out:
- data-dependent accounts, in which what is learned depends on structure in the true labels: a preference of the training procedure for low-norm, flat or simple solutions when such solutions exist, an implicit bias of training;
- bounds evaluated on the particular function found rather than on the whole class, in terms of its weight norms, its classification margin, how compressible it is, or its probability under a prior (PAC-Bayes, §6);
- a prior over functions whose support is everything but whose mass is on structured functions.
This is what the random-labels experiment alone leaves standing; §6 and §8 constrain the second item further.
The slower fit on random labels is a hint that some simplicity ordering is at work. Such a “soft” bias (the class can fit anything, but training prefers some fits) predicts things a hard restriction on the class does not:
- the same model at the same n generalizes differently depending on the labels;
- random labels take longer to fit and end at larger norm or complexity;
- adding parameters need not hurt, and can help (double descent, 1.3–1.6), whereas a bound based on the size of the class only gets worse as the class grows;
- a bound in terms of the prior mass or description length of the found function can be non-vacuous where class-size bounds are not.
2. It counts against the constraint reading used as an explanation: the networks generalize without the constraint, and with it they still fit random labels, so the constrained class is still far too large for a class-size bound. The prior reading survives if the prior is soft and implemented implicitly, by architecture, initialization and SGD. The spectral-filter reading also survives as implicit regularization: gradient descent fits the directions the data determine strongly first, stopping early leaves the others unfit, and from zero initialization gradient descent converges to the smallest-norm fit (4.3).
Exercises: double descent in least squares
This exercise derives observation 2 above exactly. The textbook picture is that test error follows a U, falling as model size grows, then rising once the model has capacity to fit noise. In least-squares regression with p parameters and n examples the rise is real, and it peaks at the interpolation threshold p=n, where the minimum-norm interpolant inverts near-zero singular values and its variance diverges. Past the threshold the test error falls again. A well-tuned ridge penalty removes the peak, and for signal-to-noise ratio above one the interpolant eventually beats even the null predictor \hat y=0. §5 asks when interpolation costs almost nothing. Sources: Hastie, Montanari, Rosset and Tibshirani (2022) for the curves (reading in §5), Nakkiran, Venkat, Kakade and Ma (2020) for 1.5.3.
Setup for 1.3–1.6. The data follow a linear model y=x^\top\beta+\varepsilon with x,\beta\in\mathbb R^p: \beta is the true coefficient vector and \varepsilon is noise. There are n training examples. Stacking their inputs as rows gives the n\times p matrix X (the design matrix) and their outputs the vector y\in\mathbb R^n, so y=X\beta+\varepsilon. Take the inputs x_i\sim\mathcal N(0,I_p) independently, the noise \varepsilon\sim\mathcal N(0,\sigma^2I_n) independent of X, and \|\beta\|^2=r^2 (r,\sigma>0); r^2/\sigma^2 is the signal-to-noise ratio. Write \gamma=p/n for the number of parameters per example. The risk of an estimate \hat\beta is its expected squared prediction error on a fresh input x_0\sim\mathcal N(0,I_p), beyond the unavoidable noise \sigma^2, averaged over the training data: \mathcal R=\mathbb E\big[(x_0^\top\hat\beta-x_0^\top\beta)^2\big]=\mathbb E\|\hat\beta-\beta\|^2, the second equality because \mathbb E[x_0x_0^\top]=I. Predicting zero (\hat\beta=0) has risk r^2. Least squares chooses \hat\beta to minimize \|y-X\hat\beta\|^2. Ridge regression adds a penalty on the size of the coefficients, \hat\beta_\lambda=\arg\min_b\big[\|y-Xb\|^2+n\lambda\|b\|^2\big]=(X^\top X+n\lambda I)^{-1}X^\top y. Limits are p,n\to\infty with p/n\to\gamma. One fact is quoted (derived in 2.3): for p<n-1, \mathbb E[(X^\top X)^{-1}]=I_p/(n-p-1), so least squares has \mathcal R=\sigma^2p/(n-p-1).
1.3. The left branch: fewer parameters than examples. For p<n the columns of X are linearly independent with probability one, so X^\top X is invertible and the least-squares estimator \hat\beta=(X^\top X)^{-1}X^\top y is unique.
- From \mathcal R=\sigma^2p/(n-p-1), derive the limit \sigma^2\gamma/(1-\gamma), which diverges as \gamma\to1. Show that \mathcal R=\sigma^2\,\mathbb E[\mathrm{Tr}(X^\top X)^{-1}]=\frac{\sigma^2}{n}\mathbb E\big[\sum_i1/\lambda_i\big], where \lambda_i are the eigenvalues of X^\top X/n, and use this to say which directions in parameter space are responsible for the divergence. You may quote the Marchenko–Pastur law: for p,n\to\infty with p/n\to\gamma\le1, the eigenvalues of X^\top X/n fill the interval [(1-\sqrt\gamma)^2,(1+\sqrt\gamma)^2]. It holds for any X with i.i.d. entries of mean zero and unit variance, Gaussian or not.
- The bias of an estimator is \mathbb E[\hat\beta]-\beta. What is the bias of least squares for \gamma<1?
Solution
1. \sigma^2\frac{p}{n-p-1}=\sigma^2\frac{p/n}{1-p/n-1/n}\to\sigma^2\frac{\gamma}{1-\gamma}. For the trace formula, \hat\beta-\beta=(X^\top X)^{-1}X^\top\varepsilon, so at fixed X, \mathbb E[\|\hat\beta-\beta\|^2\mid X]=\sigma^2\mathrm{Tr}\big[(X^\top X)^{-1}X^\top X(X^\top X)^{-1}\big]=\sigma^2\mathrm{Tr}(X^\top X)^{-1}, and \mathrm{Tr}(X^\top X)^{-1}=\frac1n\sum_i1/\lambda_i. By the Marchenko–Pastur law the eigenvalues fill [(1-\sqrt\gamma)^2,(1+\sqrt\gamma)^2], and as \gamma\to1 the lower edge tends to 0, so the smallest eigenvalues, the directions in which the data barely determine \beta, blow up the sum. Consistently, \frac1p\mathrm{Tr}(X^\top X/n)^{-1}\to\frac1{1-\gamma}.
2. Zero: \mathbb E[\hat\beta\mid X]=(X^\top X)^{-1}X^\top X\beta=\beta whenever X^\top X is invertible (2.2). Below the threshold the whole risk is variance, the fluctuation of \hat\beta around \beta caused by the noise.
1.4. The right branch: more parameters than examples. For p>n the rows of X are linearly independent with probability one, so XX^\top is invertible, and infinitely many coefficient vectors b fit the training data exactly. Among these, gradient descent from b=0 reaches the one of smallest norm (4.3.4), which is also the limit of the ridge estimator \hat\beta_\lambda as \lambda\to0^+; call it the minimum-norm interpolant. Write X^+=X^\top(XX^\top)^{-1} (the Moore–Penrose pseudoinverse of X).
- Show that \hat\beta=X^+y interpolates, and that it has the smallest norm of all interpolants.
- Let P=X^+X. Show that P is the orthogonal projection onto the row space of X, the span of the training inputs, and that \hat\beta-\beta=-(I-P)\beta+X^+\varepsilon with the two terms orthogonal. So \mathcal R=\underbrace{\mathbb E[\|(I-P)\beta\|^2]}_{\text{bias}^2}+\underbrace{\sigma^2\,\mathbb E[\mathrm{Tr}(XX^\top)^{-1}]}_{\text{variance}}: the first term is the part of \beta that the training inputs never probe, the second is the noise the fit absorbs.
- Bias. Show that \mathbb E[P]=(n/p)I, so that \text{bias}^2=r^2(1-n/p)\to r^2(1-1/\gamma).
- Variance. XX^\top=\sum_{j=1}^px_{\cdot j}x_{\cdot j}^\top is a sum of p outer products of independent \mathcal N(0,I_n) vectors, the columns of X, which is exactly the form X^\top X had with the roles of n and p exchanged. Reuse the quoted fact to get variance \sigma^2n/(p-n-1)\to\sigma^2/(\gamma-1).
- Assemble the full curve for \gamma\in(0,\infty). Describe it near \gamma=1 and as \gamma\to\infty.
Hint
For 3, use rotation invariance: for any orthogonal O\in\mathbb R^{p\times p}, XO has the same distribution as X. Combine this with \mathrm{Tr}\,P=n.
Solution
1. X\hat\beta=XX^\top(XX^\top)^{-1}y=y, so \hat\beta interpolates. Any other interpolant is \hat\beta+w with Xw=0. Now \hat\beta=X^\top(XX^\top)^{-1}y is a linear combination of the rows of X, while Xw=0 says w is orthogonal to every row, so \hat\beta\perp w and \|\hat\beta+w\|^2=\|\hat\beta\|^2+\|w\|^2\ge\|\hat\beta\|^2.
2. P=X^\top(XX^\top)^{-1}X is symmetric and satisfies P^2=P, so it is an orthogonal projection; its range lies in the row space (it is X^\top times something) and PX^\top=X^\top, so it fixes the row space and is the projection onto it. Then \hat\beta=X^+(X\beta+\varepsilon)=P\beta+X^+\varepsilon, so \hat\beta-\beta=-(I-P)\beta+X^+\varepsilon. The first term is orthogonal to the row space and the second lies in it, so the cross term vanishes. Here “bias squared” means the squared bias at fixed X, then averaged over X, rather than the bias after averaging over X. Finally \mathbb E[\|X^+\varepsilon\|^2]=\sigma^2\mathrm{Tr}(X^{+\top}X^+) and X^{+\top}X^+=(XX^\top)^{-1}XX^\top(XX^\top)^{-1}=(XX^\top)^{-1}.
3. For orthogonal O, XO has the same distribution as X (each row is a rotated standard Gaussian vector, which is again standard Gaussian), and its row-space projection is O^\top PO. So \mathbb E[P]=O^\top(\mathbb E[P])O for all O, which forces \mathbb E[P]=cI. Taking traces, \mathrm{Tr}\,P=n (a projection onto an n-dimensional space) gives c=n/p. For any fixed \beta, \mathbb E[\|(I-P)\beta\|^2]=\beta^\top(I-\mathbb E[P])\beta=r^2(1-n/p). The interpolant only sees the component of \beta along the training inputs, a random n-dimensional subspace, and misses the rest.
4. For p>n+1, the quoted fact with (n,p)\to(p,n) gives \mathbb E[(XX^\top)^{-1}]=I_n/(p-n-1), so the variance is \sigma^2n/(p-n-1)\to\sigma^2/(\gamma-1). (Hastie et al. state this branch as part of their Theorem 1. For independent Gaussian inputs it is a two-line consequence of the same fact.)
5.
\mathcal R(\gamma)=\begin{cases}\sigma^2\dfrac{\gamma}{1-\gamma},&\gamma<1,\\[2mm] r^2\Big(1-\dfrac1\gamma\Big)+\dfrac{\sigma^2}{\gamma-1},&\gamma>1.\end{cases}
The risk starts at 0, rises, and diverges at \gamma=1 from both sides; the divergence is entirely variance. Past the threshold, the bias grows from 0 toward r^2 while the variance falls from \infty toward 0. As \gamma\to\infty the risk tends to r^2, the risk of predicting zero: the training inputs span a vanishing fraction of the directions of \beta, and the noise is spread over so many directions that it does no harm. The “second descent” is the variance falling faster than the bias rises.
1.5. When does interpolation beat doing nothing, and what removes the peak? Two facts are used. First, suppose one believes before seeing data that \beta\sim\mathcal N(0,\tau^2I). Then the posterior mean of \beta given the data, which is the estimate that minimizes the squared error averaged over this prior and the noise, is exactly the ridge estimator \hat\beta_\lambda with \lambda=\sigma^2/(n\tau^2) (4.1.1). Second, the minimum-norm interpolant is the limit of \hat\beta_\lambda as \lambda\to0^+. Write \lambda^*=\sigma^2\gamma/r^2.
- For \gamma>1, minimize the risk of the minimum-norm interpolant, r^2(1-1/\gamma)+\sigma^2/(\gamma-1) over \gamma. Show that if r>\sigma (signal-to-noise ratio above one), the minimum is at \gamma=r/(r-\sigma), with value 2r\sigma-\sigma^2<r^2. Show that if r\le\sigma, the risk decreases monotonically toward r^2 from above.
- Show that \lambda^* equals \sigma^2/(n\tau^2) for the prior \beta\sim\mathcal N(0,(r^2/p)I), which has \mathbb E[\|\beta\|^2]=r^2. Hence \hat\beta_{\lambda^*} is the best possible estimator in squared error averaged over that prior.
- Use 2 to argue that (a) the risk of \hat\beta_{\lambda^*} is at most the risk of the minimum-norm interpolant at every \gamma, and (b) at fixed p the risk of \hat\beta_{\lambda^*} is non-increasing in n. Deduce that its limiting curve is non-decreasing in \gamma, so it has no peak.
Hint
For 3(a), rotating the inputs and the coefficients together (X\to XO, \beta\to O^\top\beta) leaves both estimators’ predictions unchanged, so each one’s risk depends on \beta only through \|\beta\|. Both estimators are also linear in y, so at fixed \beta the risk is a quadratic form in \beta plus a constant; with the symmetry this makes it A\|\beta\|^2+B, and averaging over the prior then gives the same value as any fixed \beta of norm r. For 3(b), what can an estimator with n+1 samples always do to guarantee it is no worse than one with n?
Solution
1. \frac{d}{d\gamma}\big[r^2(1-1/\gamma)+\sigma^2/(\gamma-1)\big]=\frac{r^2}{\gamma^2}-\frac{\sigma^2}{(\gamma-1)^2}. This vanishes when \frac{\gamma-1}{\gamma}=\frac\sigma r, i.e. \gamma^\star=\frac{1}{1-\sigma/r}=\frac{r}{r-\sigma}, which requires r>\sigma. There 1-1/\gamma^\star=\sigma/r and \gamma^\star-1=\sigma/(r-\sigma), so
\mathcal R(\gamma^\star)=r\sigma+\sigma(r-\sigma)=2r\sigma-\sigma^2=r^2-(r-\sigma)^2<r^2 .
The derivative is negative before \gamma^\star and positive after, and \mathcal R\to r^2 from below as \gamma\to\infty. So for signal-to-noise ratio above one, the interpolant beats predicting zero over a whole range of \gamma. If r\le\sigma, then \frac{\gamma-1}{\gamma}<1\le\frac\sigma r, the derivative is negative everywhere on (1,\infty), and the risk falls toward r^2 without crossing it: the interpolant never beats predicting zero.
In this model the global minimum over all \gamma is still at \gamma\to0, because r^2 is held fixed as p grows, so each added feature carries less signal. Whether adding features can win globally depends on whether they carry new signal. Hastie et al. (§5) study a variant in which the true function depends on features the model leaves out, so that adding features brings in signal the model was missing; there, for signal-to-noise ratio above one, the global minimum can lie at \gamma>1.
2. With \tau^2=r^2/p: \lambda=\frac{\sigma^2}{n\tau^2}=\frac{\sigma^2p}{nr^2}=\frac{\sigma^2\gamma}{r^2}=\lambda^*. By 4.1.1, \hat\beta_{\lambda^*} is the posterior mean, which minimizes \mathbb E[\|b-\beta\|^2] over all estimators b when \beta is drawn from that prior. (This is also 2.5.3’s best common penalty n\lambda=\sigma^2/\tau^2.)
3. (a) Both estimators are unchanged by rotating inputs and coefficients together, and the distribution of X is rotation-invariant, so each one’s risk at fixed \beta depends only on \|\beta\|. More precisely, for either estimator the risk at fixed \beta has the form A\|\beta\|^2+B: by the same symmetry the squared-bias matrix is a multiple of I, and the noise term does not involve \beta. So the risk averaged over any prior with \mathbb E[\|\beta\|^2]=r^2 equals the risk at any single vector of norm r, already at finite p (whenever the risks are finite). \hat\beta_{\lambda^*} has the smallest prior-averaged risk of any estimator, so it is at least as good as the minimum-norm interpolant at every fixed \beta of norm r. (This compares the two estimators at fixed norm; it does not make \hat\beta_{\lambda^*} the best of all estimators for a \beta drawn uniformly from the sphere.)
(b) An estimator given n+1 samples can ignore the last one, so the best estimator with n+1 samples has prior-averaged risk at most that of the best estimator with n samples. More data never hurts the posterior mean. The limiting curve depends on \gamma alone, and at fixed p increasing n decreases \gamma, so the risk of \hat\beta_{\lambda^*} is non-decreasing in \gamma. There is no peak.
The double-descent peak is therefore a property of the minimum-norm estimator, a variance divergence at p\approx n that properly tuned regularization removes, and not a property of the problem.
1.6. The curves at two signal-to-noise ratios. For r^2/\sigma^2=5 and for r^2/\sigma^2=0.5, use 1.5.1 to locate the minimum of the risk of the minimum-norm interpolant on \gamma>1, if it has one, and say whether the curve crosses r^2, the risk of predicting zero. Then sketch both curves against \gamma on a log axis, with r^2 as a horizontal line, the bias and variance contributions shaded, and the risk of \hat\beta_{\lambda^*} on the same axes, using what 1.5.3 says about its shape. The interactive figure below draws all of these.
Solution
What a correct sketch shows. For both signal-to-noise ratios, the curve starts at 0, rises as \sigma^2\gamma/(1-\gamma), and has a vertical asymptote at \gamma=1, entirely from variance; the bias is zero for \gamma<1.
- For r^2/\sigma^2=5 (r\approx2.24\sigma): past the peak the curve falls through r^2, has its minimum at \gamma=r/(r-\sigma)\approx1.81 with value 2r\sigma-\sigma^2\approx3.47\sigma^2<r^2=5\sigma^2, and then climbs back to r^2 from below.
- For r^2/\sigma^2=0.5: past the peak the curve falls toward r^2 from above and never crosses it.
The risk of \hat\beta_{\lambda^*} is a smooth, non-decreasing curve that lies below that of the minimum-norm interpolant everywhere and tends to r^2 as \gamma\to\infty.
▶ Interactive figure: double_descent.html. Turn on the bias/variance decomposition and check which term makes the peak. Toggle optimal ridge λ* = σ²γ/r². Drag the SNR across 1 and watch whether the min-norm curve dips below the null risk r². The dots are finite-n simulations: note how they scatter near γ = 1.
1.7. Is a network’s peak a variance divergence? Networks show double-descent curves in width, training time and sample size (Nakkiran et al. 2019), usually with label noise, and regularization or early stopping weakens them. The expected squared test error of a learned predictor splits into three parts (2.4.1): the noise, the squared bias of the predictor averaged over training sets, and the variance of the predictor across training sets. Describe a measurement that would tell you whether a network’s double-descent peak is a variance divergence of the kind derived in 1.4.
Solution
Train several networks of the same size on independent draws of the training data (or with different seeds and different label noise) near the apparent peak. Split the test loss into the loss of the averaged prediction (bias plus noise) and the spread of the individual predictions around it (variance), as in 2.4. If the peak is a variance divergence, the spread peaks there while the loss of the averaged prediction does not. Weight decay tuned separately at each size should then flatten the peak. A second check is the eigenvalues of whatever matrix plays the role of X^\top X/n for the network, its feature covariance: a variance divergence of the kind in 1.3 requires eigenvalues near zero.
2. Reference cases: risk, least squares, bias–variance
The textbook quantities (generalization gap, excess risk, bias and variance), computed exactly in linear regression, where claims about generalization can be checked against a closed form.
Notation: X is the n\times p design with singular values s_k, \varepsilon the label noise with variance \sigma^2, \lambda the ridge penalty in \frac1n\|y-X\beta\|^2+\lambda\|\beta\|^2 and a=n\lambda, \tau^2 a Gaussian prior variance on \beta; \mu=X\beta in 2.3.4 is the noiseless mean vector.
Bias–variance tradeoff, Wikipedia
The decomposition of expected squared error into bias, variance and noise, with the least-squares case worked out; 2.4–2.5 derive it for ridge.
Lecture 08: Bias-Variance Tradeoff, Yaser Abu-Mostafa (Caltech, Learning from Data, 2012; YouTube)
A lecture on the same decomposition, with a worked example of a constant fit against a line fit.
For reference (books): The Elements of Statistical Learning, Hastie, Tibshirani and Friedman (2nd ed. 2009; free PDF), §3.2, §3.4.1, §7.2–7.4.
Exercises: generalization gap and excess risk
“Deep networks generalize well” is said about two different quantities, and papers switch between them.
Setup. Data z=(x,y) are drawn i.i.d. from an unknown P; the training sample is S=(z_1,\dots,z_n). A loss \ell(\theta;z) scores parameters \theta on one example. The population risk is R(\theta)=\mathbb E_{z\sim P}\ell(\theta;z), the empirical risk \hat R_n(\theta)=\frac1n\sum_i\ell(\theta;z_i). A learning rule maps S to \hat\theta_n; empirical risk minimization (ERM) takes \hat\theta_n\in\arg\min\hat R_n. The population minimizer is \theta^*\in\arg\min R. For any learning rule define
\mathrm{gap}_n=R(\hat\theta_n)-\hat R_n(\hat\theta_n), \qquad \mathcal E_n=R(\hat\theta_n)-R(\theta^*).
The generalization gap asks whether the training loss is an honest estimate of the test loss; the excess risk asks whether the learner found a good model.
2.1. Gap without excess, excess without gap.
- Construct a model class and a distribution in which ERM has excess risk exactly zero but a gap equal to the noise variance.
- Construct a learning rule with expected gap exactly zero but excess risk bounded away from zero.
- Show that for ERM, \mathbb E\,\mathcal E_n\le\mathbb E\,\mathrm{gap}_n, and that \mathcal E_n\le 2\sup_\theta|R(\theta)-\hat R_n(\theta)|.
- You have a held-out set of m fresh samples from P. Which of the two quantities can you estimate, and how accurately? What would you need in order to estimate the other?
Hint
For 1, use squared loss with a continuous input, and let the class contain functions that agree with the best predictor except on a finite set of points. For 2, the rule need not look at the data. For 3, telescope \mathcal E_n through \hat R_n(\hat\theta_n) and \hat R_n(\theta^*), and ask which terms depend on S in a way that matters.
Solution
1. Take x\sim\mathrm{Unif}[0,1] and y=f^*(x)+\varepsilon with \varepsilon\sim\mathcal N(0,\sigma^2), under squared loss. Let the class be f^* together with every “patched” function f_T, where T is a finite set of labelled points with distinct inputs: f_T(x)=y if (x,y)\in T and f_T(x)=f^*(x) otherwise. Each f_T differs from f^* on a set of measure zero, so R(f_T)=R(f^*)=\sigma^2 and every member of the class is a population minimizer. ERM returns f_S, which has zero training loss because the x_i are almost surely distinct. Hence
\mathcal E_n=0,\qquad \mathrm{gap}_n=\sigma^2 .
Memorizing costs nothing here because the memorized inputs never recur. This is a caricature of benign overfitting; 5.2–5.3 have a real version.
2. Take the rule that ignores the data and outputs a fixed \theta_0 with R(\theta_0)>R(\theta^*). Since \theta_0 does not depend on S, \mathbb E\hat R_n(\theta_0)=R(\theta_0), so \mathbb E\,\mathrm{gap}_n=0. Meanwhile \mathcal E_n=R(\theta_0)-R(\theta^*)>0 for every S. A small gap means the training loss is an honest estimate of the test loss, not that the model is good.
3. Write
\mathcal E_n=\underbrace{R(\hat\theta_n)-\hat R_n(\hat\theta_n)}_{\mathrm{gap}_n} +\underbrace{\hat R_n(\hat\theta_n)-\hat R_n(\theta^*)}_{\le 0\ \text{(ERM)}} +\underbrace{\hat R_n(\theta^*)-R(\theta^*)}_{\text{mean }0}.
The middle term is non-positive because \hat\theta_n minimizes \hat R_n. The last has mean zero because \theta^* does not depend on S. Taking expectations gives \mathbb E\,\mathcal E_n\le\mathbb E\,\mathrm{gap}_n. Bounding the first and third terms by \sup_\theta|R-\hat R_n| and dropping the middle one gives \mathcal E_n\le2\sup_\theta|R(\theta)-\hat R_n(\theta)|. This is the route every capacity bound takes (§3, 1.1): control the worst gap over the whole class, and the excess risk follows.
4. Because \hat\theta_n is independent of the held-out data, the held-out mean loss is unbiased for R(\hat\theta_n), with standard error \mathrm{sd}(\ell)/\sqrt m. Subtracting the training loss estimates the gap. The excess risk also needs R(\theta^*), the best achievable loss in the class, which a held-out loss alone does not identify without further assumptions or knowledge. You can measure differences of excess risk between two fitted predictors in the same model class, since R(\theta^*) cancels. Different classes can have different optimum risks. More generally, a held-out set estimates the population loss of whatever predictor you evaluate on it, whether one network or an ensemble.
A sanity example with both quantities nonzero: for constant predictors on y\sim\mathcal N(\mu,\sigma^2), \hat\theta_n=\bar y, \mathbb E\,\mathcal E_n=\sigma^2/n and \mathbb E\,\mathrm{gap}_n=2\sigma^2/n.
Exercises: least squares, exactly
The “parameter counting” answer, about \sigma^2/n of excess risk per parameter, and where it breaks down as p approaches n.
Setup for 2.2–2.3. The linear model is y=x^\top\beta+\varepsilon, with x,\beta\in\mathbb R^p and noise \varepsilon of mean 0 and variance \sigma^2, independent of x. Stack the n training inputs as the rows of the design matrix X\in\mathbb R^{n\times p} and the targets as y\in\mathbb R^n, so y=X\beta+\varepsilon. Take \varepsilon\sim\mathcal N(0,\sigma^2I_n), n>p, and X of full column rank. Ordinary least squares (OLS) is ERM with \hat R_n(b)=\frac1n\|y-Xb\|^2. For the population, take a fresh x\sim\mathcal N(0,I_p). The thin SVD X=\sum_ks_ku_kv_k^\top has singular values s_k>0; directions v_k with small s_k are the ones the data barely determine.
2.2. Mean, covariance and excess risk at a fixed design.
- Derive \hat\beta=(X^\top X)^{-1}X^\top y, and show \mathbb E\hat\beta=\beta and \mathrm{Cov}\,\hat\beta=\sigma^2(X^\top X)^{-1}. Here expectations are over the noise, with X fixed.
- Show that R(b)=\sigma^2+\|b-\beta\|^2. Hence \theta^*=\beta, \mathcal E_n=\|\hat\beta-\beta\|^2, and \mathbb E[\mathcal E_n\mid X]=\sigma^2\,\mathrm{Tr}\,(X^\top X)^{-1}.
- Show that the expected training risk is \mathbb E[\hat R_n(\hat\beta)\mid X]=\sigma^2(n-p)/n.
Hint
For 3, the residual is (I-P_X)\varepsilon, where P_X=X(X^\top X)^{-1}X^\top is a rank-p orthogonal projection.
Solution
1. \nabla_b\hat R_n=-\frac2nX^\top(y-Xb)=0 gives the normal equations X^\top Xb=X^\top y. Since X^\top X is invertible, \hat\beta=(X^\top X)^{-1}X^\top y. Substituting y=X\beta+\varepsilon,
\hat\beta=\beta+(X^\top X)^{-1}X^\top\varepsilon,
so \mathbb E\hat\beta=\beta, and
\mathrm{Cov}\,\hat\beta=(X^\top X)^{-1}X^\top(\sigma^2I)X(X^\top X)^{-1}=\sigma^2(X^\top X)^{-1}.
2. R(b)=\mathbb E(x^\top\beta+\varepsilon-x^\top b)^2=\sigma^2+(\beta-b)^\top\mathbb E[xx^\top]\,(\beta-b)=\sigma^2+\|b-\beta\|^2, since \varepsilon is independent of x and \mathbb E xx^\top=I. So \theta^*=\beta, R(\theta^*)=\sigma^2 and \mathcal E_n=\|\hat\beta-\beta\|^2. Then
\mathbb E\|\hat\beta-\beta\|^2=\mathrm{Tr}\,\mathrm{Cov}\,\hat\beta=\sigma^2\,\mathrm{Tr}\,(X^\top X)^{-1}.
3. The residual is y-X\hat\beta=(I-P_X)y=(I-P_X)\varepsilon, because (I-P_X)X=0. So \mathbb E\|y-X\hat\beta\|^2=\sigma^2\,\mathrm{Tr}(I-P_X)=\sigma^2(n-p), and dividing by n gives \sigma^2(n-p)/n. The fit absorbs the noise along p directions, so the training loss underestimates \sigma^2.
2.3. Random design: parameter counting. Now let the rows of X be i.i.d. \mathcal N(0,I_p), so X^\top X is Wishart.
- Show that \mathbb E[(X^\top X)^{-1}]=I_p/(n-p-1) for n>p+1. Conclude that \mathbb E\,\mathcal E_n=\sigma^2p/(n-p-1).
- Compute the expected gap exactly, and show that for n\gg p the excess risk is \approx\sigma^2p/n while the gap is \approx2\sigma^2p/n. Where does the factor of two come from?
- What happens as p\to n-1? Which eigenvalues of X^\top X are responsible?
Hint
Rotation invariance shows that \mathbb E(X^\top X)^{-1} is a multiple of I. For a diagonal entry, the block-inverse (Schur complement) formula gives [(X^\top X)^{-1}]_{11}=1/\big(x_{\cdot1}^\top(I-P_{-1})x_{\cdot1}\big). Here x_{\cdot1}\in\mathbb R^n is the first column of X and P_{-1} projects onto the span of the other p-1 columns. What is the law of the denominator? You may use \mathbb E[1/\chi^2_k]=1/(k-2).
Solution
1. Proportional to I. For any orthogonal O\in\mathbb R^{p\times p}, XO has the same law as X, and ((XO)^\top XO)^{-1}=O^\top(X^\top X)^{-1}O. So M=\mathbb E(X^\top X)^{-1} satisfies M=O^\top MO for all O, which forces M=cI.
The constant. By the Schur complement, [(X^\top X)^{-1}]_{11}=1/\big(x_{\cdot1}^\top(I-P_{-1})x_{\cdot1}\big). Conditional on the other columns, I-P_{-1} is an orthogonal projection of rank n-p+1, and it is independent of x_{\cdot1}\sim\mathcal N(0,I_n). So the denominator is \chi^2_{n-p+1}. Next, \mathbb E[1/\chi^2_k]=\frac{\Gamma(k/2-1)}{2\Gamma(k/2)}=\frac1{k-2} for k>2, which gives c=1/(n-p-1). Combining with 2.2.2,
\mathbb E\,\mathcal E_n=\sigma^2\,\mathrm{Tr}\,\mathbb E(X^\top X)^{-1}=\frac{\sigma^2p}{n-p-1}.
2. \mathbb E R(\hat\beta)=\sigma^2+\sigma^2p/(n-p-1)=\sigma^2\frac{n-1}{n-p-1}, and by 2.2.3, \mathbb E\hat R_n(\hat\beta)=\sigma^2\frac{n-p}{n}. So
\mathbb E\,\mathrm{gap}_n=\sigma^2\Big[\frac{n-1}{n-p-1}-\frac{n-p}{n}\Big] \approx\sigma^2\Big[\Big(1+\frac pn\Big)-\Big(1-\frac pn\Big)\Big]=\frac{2\sigma^2p}{n}.
The test loss overestimates \sigma^2 by about \sigma^2p/n (the excess risk), and the training loss underestimates it by the same amount, because the fit has absorbed the noise along p directions. The gap counts both. This is the factor of two between “optimism” and “excess risk” that 7.2 derives in general (TIC vs \tfrac1{2n}\mathrm{Tr}(H^{-1}C)).
3. Each of the p coefficients is estimated with variance \approx\sigma^2/n, which is “parameter counting”. The exact correction n/(n-p-1) diverges as p\to n-1. The cause is the smallest eigenvalues of X^\top X/n. When p/n\to\gamma<1, its spectrum fills [(1-\sqrt\gamma)^2,(1+\sqrt\gamma)^2] (Marchenko–Pastur, quoted), and \mathrm{Tr}(X^\top X)^{-1}=\frac1n\sum_i 1/\lambda_i(X^\top X/n) is dominated by the eigenvalues near the lower edge, which tends to 0 as \gamma\to1. Noise along nearly degenerate directions of the design is amplified without limit. The keystone exercises (1.3) pick this up.
(All of these formulas are checked by Monte Carlo in checks/wb2a_check.py.)
Exercises: bias–variance
Why a model that fits its training data worse can predict better, and where the decomposition stops being true.
2.4. Decompose, then decompose a posterior. Let y=f(x)+\varepsilon, where f is the true regression function, \mathbb E[\varepsilon\mid x]=0 and \mathrm{Var}[\varepsilon\mid x]=\sigma^2(x). A predictor \hat f_S is trained on a random sample S, independent of the test point. Fix a test input x; expectations are over S and the test noise.
- Show that \mathbb E_{S,\varepsilon}\big(\hat f_S(x)-y\big)^2=\sigma^2(x)+\big(\mathbb E_S\hat f_S(x)-f(x)\big)^2+\mathrm{Var}_S\hat f_S(x).
- Average K predictors trained on independent samples. Which terms change, and by how much?
- The same algebra with a different source of randomness. Let q be any distribution over parameters, for instance a posterior given S, with predictive mean \bar f(x)=\mathbb E_{\theta\sim q}f_\theta(x). Show that for squared loss \mathbb E_{\theta\sim q}\big(f_\theta(x)-y\big)^2=\big(\bar f(x)-y\big)^2+\mathrm{Var}_{\theta\sim q}f_\theta(x). Translate this into a statement comparing a single posterior draw with the posterior-predictive mean. (7.6 calls their errors the Gibbs and Bayes errors.)
- Does 1 hold for 0–1 loss? Give an example where more variance lowers the expected 0–1 error.
Solution
1. Write \hat f_S(x)-y=(\hat f_S-\mathbb E\hat f_S)+(\mathbb E\hat f_S-f)+(f-y) and square. The cross terms vanish in expectation. (\hat f_S-\mathbb E\hat f_S) has mean zero over S. (f-y)=-\varepsilon has mean zero and is independent of S. (\mathbb E\hat f_S-f) is a constant. What remains is variance, plus squared bias, plus \sigma^2(x).
2. The average of K independent copies has the same mean, hence the same bias, and variance \mathrm{Var}_S\hat f_S(x)/K. The noise term is untouched. (Real bagging resamples a single dataset, so the copies are correlated and the reduction is smaller.)
3. Expand f_\theta-y=(f_\theta-\bar f)+(\bar f-y) and take \mathbb E_{\theta\sim q} with x,y fixed. The cross term is 2(\bar f-y)\,\mathbb E_q[f_\theta-\bar f]=0. With q a posterior, the left side is the Gibbs loss at (x,y) and (\bar f-y)^2 is the Bayes-ensemble loss. Averaging over (x,y):
\text{Gibbs error}=\text{Bayes-ensemble error}+\mathbb E_x\,\mathrm{Var}_{\text{post}}f_\theta(x)\ \ge\ \text{Bayes-ensemble error},
with equality iff the posterior predictors agree for almost every input under the test distribution. For squared loss, ensembling never hurts a posterior draw. 7.6 finds that in the regular case the excess parts differ by a factor of two (p/n vs p/2n).
4. No: the 0–1 loss does not decompose additively. Take y=1 deterministically and predict \mathbf 1[\hat g_S(x)>0], where \hat g_S(x)\sim\mathcal N(\mu,v) with \mu<0, so the average prediction is on the wrong side. The error is \Pr[\hat g_S\le0]=\Phi(-\mu/\sqrt v), which decreases toward \tfrac12 as v grows. When the bias has the wrong sign, variance helps. “Variance always hurts” is a fact about squared loss.
2.5. Ridge in the eigenbasis: bias and variance per direction. Take the linear model y=X\beta+\varepsilon with a fixed n\times p design X and noise \varepsilon\sim(0,\sigma^2I_n), \sigma^2>0. For the comparisons with OLS assume X has full column rank. Ridge regression is
\hat\beta_\lambda=\arg\min_b\ \tfrac1n\|y-Xb\|^2+\lambda\|b\|^2=(X^\top X+n\lambda I)^{-1}X^\top y .
Write X^\top X=V\,\mathrm{diag}(s_1^2,\dots,s_p^2)\,V^\top, with v_k the columns of V, \beta_k=v_k^\top\beta, and a=n\lambda. Track the parameter error \mathbb E\|\hat\beta_\lambda-\beta\|^2, which equals the excess population risk when test inputs are x\sim\mathcal N(0,I) (2.2.2).
- Show that, in coordinates v_k^\top\hat\beta_\lambda, \mathrm{bias}_k=-\frac{a}{s_k^2+a}\,\beta_k,\qquad \mathrm{var}_k=\sigma^2\frac{s_k^2}{(s_k^2+a)^2}, and that different coordinates are uncorrelated. Hence \mathbb E\|\hat\beta_\lambda-\beta\|^2=\sum_k\dfrac{a^2\beta_k^2+\sigma^2s_k^2}{(s_k^2+a)^2}.
- Which directions carry most of the variance at \lambda=0? Show that the derivative of the total error with respect to a at a=0 is strictly negative, so some ridge always beats OLS.
- Allow a separate penalty a_k in each direction. Show that the optimum is a_k=\sigma^2/\beta_k^2, independent of s_k, and that the minimal error in that direction is \big(s_k^2/\sigma^2+1/\beta_k^2\big)^{-1}. If \beta\sim\mathcal N(0,\tau^2I), show that the best common penalty is a=\sigma^2/\tau^2.
- Effective degrees of freedom. The fitted values are \hat y=S_\lambda y with S_\lambda=X(X^\top X+aI)^{-1}X^\top. Show that \mathrm{Tr}\,S_\lambda=\mathrm{df}(\lambda)=\sum_k s_k^2/(s_k^2+a). Then show that the in-sample optimism, \mathbb E\frac1n\|y'-\hat y\|^2-\mathbb E\frac1n\|y-\hat y\|^2 for fresh noise y'=X\beta+\varepsilon' at the same inputs, equals 2\sigma^2\,\mathrm{df}(\lambda)/n. Compare with 2.3.
Hint
For 1, \mathbb E\hat\beta_\lambda=(X^\top X+aI)^{-1}X^\top X\beta, and the covariance is \sigma^2(X^\top X+aI)^{-1}X^\top X(X^\top X+aI)^{-1}. All of these matrices are diagonal in V. For 3, differentiate f(a)=(a^2\beta^2+\sigma^2s^2)/(s^2+a)^2; the numerator of f' factors. For 4, expand both squared norms around X\beta. The only surviving difference is \mathbb E\langle\varepsilon,S_\lambda\varepsilon\rangle.
Solution
1. \mathbb E\hat\beta_\lambda=(X^\top X+aI)^{-1}X^\top X\beta, so in the V basis coordinate k is \frac{s_k^2}{s_k^2+a}\beta_k and the bias is \big(\frac{s_k^2}{s_k^2+a}-1\big)\beta_k=-\frac{a}{s_k^2+a}\beta_k. The covariance is \sigma^2(X^\top X+aI)^{-1}X^\top X(X^\top X+aI)^{-1}=V\,\mathrm{diag}\!\big(\sigma^2s_k^2/(s_k^2+a)^2\big)V^\top, which is diagonal in V, so the coordinates are uncorrelated. Summing squared bias and variance over k gives the total.
2. At a=0, \mathrm{var}_k=\sigma^2/s_k^2, so the weakest directions (small s_k) dominate. That is the same \mathrm{Tr}(X^\top X)^{-1} as in 2.2.2. Write f_k(a)=\frac{a^2\beta_k^2+\sigma^2s_k^2}{(s_k^2+a)^2}. Then
f_k'(a)=\frac{2a\beta_k^2(s_k^2+a)-2(a^2\beta_k^2+\sigma^2s_k^2)}{(s_k^2+a)^3}=\frac{2s_k^2(a\beta_k^2-\sigma^2)}{(s_k^2+a)^3}.
At a=0 this is -2\sigma^2/s_k^4<0 for every k, so a small amount of ridge lowers the total error, for every \beta. This is the observation of Hoerl and Kennard (1970).
3. By the factored derivative, f_k decreases for a<\sigma^2/\beta_k^2 and increases after, so a_k^*=\sigma^2/\beta_k^2, which does not involve s_k. Substituting,
f_k(a_k^*)=\frac{\sigma^2(\sigma^2+s_k^2\beta_k^2)/\beta_k^2}{(s_k^2\beta_k^2+\sigma^2)^2/\beta_k^4}=\frac{\sigma^2\beta_k^2}{s_k^2\beta_k^2+\sigma^2}=\Big(\frac{s_k^2}{\sigma^2}+\frac1{\beta_k^2}\Big)^{-1}.
If \beta_k=0, the optimum is the limit a_k\to\infty, with zero error. This has the form of a posterior variance: data precision plus prior precision. If \beta\sim\mathcal N(0,\tau^2I), then \mathbb E\beta_k^2=\tau^2, and \mathbb E_\beta f_k(a)=\frac{a^2\tau^2+\sigma^2s_k^2}{(s_k^2+a)^2} is minimized at a=\sigma^2/\tau^2 for every k at once. So the best common penalty is n\lambda=\sigma^2/\tau^2. 4.1 gets the same value as the MAP prior, and 1.5.2 as the optimal \lambda^*=\sigma^2\gamma/r^2 for random designs, where \gamma=p/n, r^2=\|\beta\|^2 and \tau^2=r^2/p.
4. With the thin SVD X=U\,\mathrm{diag}(s_k)V^\top, S_\lambda=U\,\mathrm{diag}\big(s_k^2/(s_k^2+a)\big)U^\top, so \mathrm{Tr}\,S_\lambda=\sum_k s_k^2/(s_k^2+a)\in[0,p]. Let \mu=X\beta. Then
\|y'-\hat y\|^2=\|\varepsilon'\|^2+\|\mu-\hat y\|^2+2\langle\varepsilon',\mu-\hat y\rangle,\qquad \|y-\hat y\|^2=\|\varepsilon\|^2+\|\mu-\hat y\|^2+2\langle\varepsilon,\mu-\hat y\rangle .
The first cross term has mean 0 because \varepsilon' is independent of \hat y. In the second, \mu-\hat y=(I-S_\lambda)\mu-S_\lambda\varepsilon, so \mathbb E\langle\varepsilon,\mu-\hat y\rangle=-\sigma^2\,\mathrm{Tr}\,S_\lambda. The difference is 2\sigma^2\,\mathrm{Tr}\,S_\lambda, and dividing by n gives 2\sigma^2\mathrm{df}(\lambda)/n. At \lambda=0, \mathrm{df}=p, which has the same leading 2\sigma^2p/n value as 2.3. Here it is exact for new labels at the training inputs; 2.3 evaluates fresh random inputs, so its finite-sample gap differs. Ridge replaces “count the parameters” with “count the directions the data can resolve against the penalty.”
3. Theorems that seem to forbid learning
No free lunch, universal approximation and capacity bounds each seem to say deep learning should be impossible or unexplained; each is true, and the exercises find the assumption that keeps it from biting.
Notation: d is the input dimension, d_{\mathrm{VC}} the VC dimension, m a number of points; the \alpha_i in 3.3 are Radon coefficients. No ridge penalty appears in this section.
No free lunch theorem, Wikipedia
Averaged uniformly over all targets, every learner does equally well off the training set; 3.1 proves the core of it and finds the assumption that breaks the average.
Universal approximation theorem, Wikipedia
The statements for width and for depth, with the conditions on the activation; 3.2 asks what the theorem does not say about how many units are needed.
Representation benefits of deep feedforward networks, Matus Telgarsky (2015)
A short depth-separation construction: composing a tent map gives exponentially many linear pieces that shallow networks need exponentially many units to match (3.2.4).
VC dimension, Wikipedia
Shattering, the definition, and the standard examples; 3.3 computes it for a few classes, including a one-parameter class with infinite VC dimension.
Also: Wolpert (1996), the original off-training-set no-free-lunch theorem; Leshno, Lin, Pinkus and Schocken (1993), universal approximation holds exactly for non-polynomial activations; Bartlett, Harvey, Liaw and Mehrabian (2019), the VC dimension of ReLU networks with W weights in L layers is O(WL\log W), and some architectures reach \Omega(WL\log(W/L)).
For reference (books): Understanding Machine Learning: From Theory to Algorithms, Shalev-Shwartz and Ben-David (2014; free PDF), §2.3, ch. 4–6, §7.3.
Exercises: no free lunch
3.1. Prove NFL, then find the bet. Let the input domain \mathcal X be finite, |\mathcal X|=N, and the target a binary function f:\mathcal X\to\{0,1\}. A training set consists of inputs x_1,\dots,x_n, chosen independently of f, with labels f(x_i); at least one input remains unseen. A learner is any map, possibly randomized, from the labelled sample to a hypothesis h:\mathcal X\to\{0,1\}. With U the set of unseen inputs, the off-training-set error is \mathrm{err}_{\mathrm{OTS}}(h,f)=\frac1{|U|}\sum_{x\in U}\mathbf 1[h(x)\ne f(x)].
- Let f be uniform over all 2^N functions. Prove that every learner has expected off-training-set error exactly \tfrac12, conditional on any training inputs.
- Conclude that for any two learners A and B, \sum_f\big[\mathrm{err}_{\mathrm{OTS}}(A,f)-\mathrm{err}_{\mathrm{OTS}}(B,f)\big]=0. What does this say about a learner that beats another on some targets?
- Now let f lie in a class \mathcal F with |\mathcal F|=M, and let the inputs be i.i.d. from a distribution D on \mathcal X. Show that a learner returning any h\in\mathcal F consistent with the sample (agreeing with f on every training input) satisfies \Pr[\mathrm{err}_D(h)>\epsilon]\le Me^{-n\epsilon}, where \mathrm{err}_D is the error under D. How many samples suffice if \mathcal F is the set of functions computed by programs of at most b bits? What does the bound give for the class of all functions?
- Where in the proof of 1 did the uniform prior enter? Give priors over targets under which the training labels are informative about the unseen ones, and say which kind of learner each favours.
Hint
For 1, condition on the training labels. Under the uniform prior, the values f(x) are independent fair coins, so what is the conditional law of f on U? For 3, a fixed h with error above \epsilon survives n i.i.d. samples with probability at most (1-\epsilon)^n. Then take a union bound.
Solution
1. Under the uniform prior, the values \{f(x)\}_{x\in\mathcal X} are i.i.d. fair coins. Condition on the training inputs and their labels. The values \{f(x)\}_{x\in U} are still i.i.d. fair coins, independent of everything the learner sees. The hypothesis h is a function of the training labels and of independent internal randomness, so h is independent of f|_U. Hence \Pr[h(x)\ne f(x)]=\tfrac12 for each x\in U, and the average over U has expectation \tfrac12.
2. By 1, \sum_f\mathrm{err}_{\mathrm{OTS}}(A,f)=2^N\cdot\tfrac12=\sum_f\mathrm{err}_{\mathrm{OTS}}(B,f), so the difference sums to zero. Whatever advantage A has over B on one set of targets, it gives back exactly on the complement. No learner is better than another “in general”, even the learner that predicts the opposite of the majority label.
3. Fix h with \mathrm{err}_D(h)>\epsilon. Each i.i.d. sample is consistent with it with probability below 1-\epsilon, so \Pr[h\text{ consistent with all }n]\le(1-\epsilon)^n\le e^{-n\epsilon}. There are at most M such h, so by the union bound \Pr[\exists\text{ consistent }h\text{ with }\mathrm{err}_D(h)>\epsilon]\le Me^{-n\epsilon}. Equivalently, with probability at least 1-\delta, every consistent h has \mathrm{err}_D(h)\le(\ln M+\ln(1/\delta))/n. For programs of at most b bits, M<2^{b+1}, so n\approx(b\ln2+\ln(1/\delta))/\epsilon samples suffice. The cost of learning scales with the description length of the target (Occam). For the class of all functions, M=2^N, and the bound needs n\gtrsim N\ln2/\epsilon: you must see a constant fraction of the domain, which is NFL again.
4. It entered at “f|_U is independent of the labels on the training set”. Any prior under which seen labels are informative about unseen ones escapes NFL. Examples:
- a simplicity (Solomonoff) prior, which favours the shortest consistent program (MDL3);
- a smoothness prior, which favours kernel or nearest-neighbour methods;
- a symmetry prior, which favours equivariant architectures such as CNNs (MDL2).
The question “why does deep learning generalize?” becomes: which prior over targets do the architecture and the optimizer implement, and why does it match the world?
Exercises: universal approximation
3.2. How many units for \sin\omega x? The universal approximation theorem (quoted): for any continuous f on a compact K\subset\mathbb R^d and any \epsilon>0, a one-hidden-layer network with a continuous non-polynomial activation (for example ReLU) achieves \sup_K|f-g|<\epsilon. It says nothing about how many units are needed.
- Show that a continuous piecewise-linear function on [0,1] with K pieces is exactly a one-hidden-layer ReLU network with K units plus an output bias.
- Upper bound. Show that the piecewise-linear interpolant of \sin(\omega x) at K+1 equally spaced knots has sup error at most \omega^2/(8K^2). Deduce that \lceil\omega/\sqrt{8\epsilon}\,\rceil units suffice for accuracy \epsilon.
- Lower bound. Show that a one-hidden-layer ReLU network with m units on \mathbb R is piecewise linear with at most m+1 pieces. Then show that for \epsilon<1 accuracy, m must grow at least like \omega/(2\pi).
- Depth. Let t(x)=2\,\mathrm{ReLU}(x)-4\,\mathrm{ReLU}(x-\tfrac12), the tent map on [0,1]. Show that the k-fold composition t^{\circ k} has 2^k linear pieces. Conclude that a depth-k network with 2k units computes a function that any one-hidden-layer network needs at least 2^k-1 units to represent.
- List three things the theorem does not tell you.
Hint
For 2, the interpolation error on an interval [a,b] is e(x)=\tfrac12f''(\xi)(x-a)(x-b). For 3, the extrema of \sin\omega x alternate between +1 and -1. On a piece where g is affine, can g be positive, negative, positive at three consecutive extrema? For 4, t maps each half of [0,1] monotonically onto [0,1].
Solution
1. Let the breakpoints be 0=t_0<t_1<\dots<t_{K-1}<1, with slopes a_0,\dots,a_{K-1} on the pieces. Then on [0,1]
g(x)=g(0)+a_0\,\mathrm{ReLU}(x-t_0)+\sum_{k=1}^{K-1}(a_k-a_{k-1})\,\mathrm{ReLU}(x-t_k),
since each ReLU switches on the slope change at its breakpoint. That is K units plus a bias.
2. On a knot interval of length h=1/K, the interpolation error is e(x)=\tfrac12f''(\xi)(x-a)(x-b), and |(x-a)(x-b)|\le h^2/4. With |f''|\le\omega^2 this gives |e|\le\omega^2h^2/8=\omega^2/(8K^2). Setting \omega^2/(8K^2)\le\epsilon gives K\ge\omega/\sqrt{8\epsilon}, so m=\lceil\omega/\sqrt{8\epsilon}\rceil units suffice. The count is linear in the frequency.
3. Each unit \mathrm{ReLU}(wx+b) has at most one breakpoint, so the sum has at most m breakpoints and at most m+1 affine pieces. The extrema of \sin\omega x in [0,1] are at x_j=(\pi/2+j\pi)/\omega, with values (-1)^j, and there are J=\lfloor\omega/\pi-\tfrac12\rfloor+1 of them. If \sup|g-\sin\omega x|<1, then g(x_j) has sign (-1)^j. An affine function that is positive at x_j and x_{j+2} is positive at x_{j+1}, which lies between them. So a single piece contains at most two consecutive extrema, and J\le2(m+1), i.e. m\ge J/2-1\approx\omega/(2\pi). Together with 2, the number of units needed is \Theta(\omega) at fixed accuracy.
4. On [0,\tfrac12], t(x)=2x is an increasing bijection onto [0,1]; on [\tfrac12,1], t(x)=2-2x is a decreasing bijection onto [0,1]. So t^{\circ k}=t^{\circ(k-1)}\circ t consists of two reparametrized copies of t^{\circ(k-1)}, one of them reversed, and by induction it has 2\cdot2^{k-1}=2^k pieces. Each layer uses 2 units, so the depth-k network has 2k units. By 3, one hidden layer needs m+1\ge2^k units. Depth buys pieces exponentially.
5. UAT does not tell you:
- how many units are needed. For generic Lipschitz targets in d dimensions the count grows like \epsilon^{-d}.
- whether gradient descent finds the approximant.
- how many samples identify it, or which of the many interpolants of the data training selects.
Polynomials (Weierstrass) and lookup tables are universal approximators too. Expressivity is cheap, so it cannot be what distinguishes networks. UAT rules out “the net cannot represent the target” and nothing else.
Exercises: VC dimension
The finite-class bound charges \ln|\mathcal H|, which is infinite for any class with a real-valued parameter. What matters on n points is how many labellings the class produces, and that is not the number of parameters.
3.3. Shattering and VC dimension. Let \mathcal H be a class of binary classifiers h:\mathcal X\to\{0,1\}. A finite set C=\{x_1,\dots,x_m\} is shattered by \mathcal H if all 2^m labellings of C are produced by some h\in\mathcal H. The growth function \Pi_{\mathcal H}(m) is the largest number of distinct labellings \mathcal H produces on any m points. The VC dimension d_{\mathrm{VC}}(\mathcal H) is the largest m for which some m-point set is shattered. To prove d_{\mathrm{VC}}=d, exhibit one shattered set of d points and show that no set of d+1 points is shattered. Two facts are quoted. Sauer–Shelah: if d_{\mathrm{VC}}=d<\infty, then \Pi_{\mathcal H}(m)\le\sum_{i=0}^{d}\binom mi\le(em/d)^d for m\ge d. VC bound (Mohri, Rostamizadeh and Talwalkar, Foundations of Machine Learning, 2nd ed., Cor. 3.19): with probability at least 1-\delta, for all h\in\mathcal H, R(h)\le\hat R_n(h)+\sqrt{2d\ln(en/d)/n}+\sqrt{\ln(1/\delta)/(2n)}, which says something only when n\gg d.
- Thresholds on \mathbb R: h_t(x)=\mathbf 1[x\ge t], t\in\mathbb R. Show d_{\mathrm{VC}}=1 and \Pi(m)=m+1.
- Intervals on \mathbb R: h_{a,b}(x)=\mathbf 1[a\le x\le b]. Show d_{\mathrm{VC}}=2, compute \Pi(m), and compare with the Sauer–Shelah bound.
- Affine halfspaces in \mathbb R^d: h_{w,b}(x)=\mathbf 1[w^\top x+b\ge0], with d+1 parameters. Show that the d+1 points 0,e_1,\dots,e_d are shattered. Then use Radon’s theorem (any d+2 points in \mathbb R^d can be split into two groups whose convex hulls intersect) to show that no d+2 points are shattered, so d_{\mathrm{VC}}=d+1. Optionally, prove Radon’s theorem.
- One parameter, infinite VC dimension. Let h_\omega(x)=\mathbf 1[\sin(\omega x)>0] with \omega>0. Take x_i=2^{-i} for i=1,\dots,m, any labels y_1,\dots,y_m\in\{0,1\}, and \omega=\pi\big(1+\sum_{j=1}^m(1-y_j)2^j\big). Show that h_\omega(x_i)=y_i for all i, so d_{\mathrm{VC}}=\infty. What does this say about counting parameters? What changes if \omega is stored as a 32-bit float?
Hint
For 2, sort the points: which patterns of 0s and 1s can an interval cut out? For 3, the halfspace \{x:w^\top x+b\ge0\} and its complement are both convex. For Radon, solve \sum_i\alpha_ix_i=0, \sum_i\alpha_i=0 and split the points by the sign of \alpha_i. For 4, compute \omega x_i/\pi modulo 2: the terms with j>i are even integers.
Solution
1. One point x is shattered: t\le x labels it 1 and t>x labels it 0. For two points x_1<x_2, the labelling (1,0) needs t\le x_1 and t>x_2, which is impossible. So d_{\mathrm{VC}}=1. On m distinct sorted points the achievable labellings are 0\cdots01\cdots1, fixed by the number k\in\{0,\dots,m\} of zeros. So \Pi(m)=m+1=\binom m0+\binom m1, and Sauer–Shelah holds with equality.
2. Two points x_1<x_2: a long interval gives (1,1), a short interval around one point gives (1,0) or (0,1), and an interval away from both gives (0,0). Three points x_1<x_2<x_3: an interval containing x_1 and x_3 contains x_2, so (1,0,1) is impossible, and d_{\mathrm{VC}}=2. On m sorted points the 1s must form one contiguous block. There is the empty block, plus one block for each choice of first and last point i\le j, which gives
\Pi(m)=1+\frac{m(m+1)}2=\binom m0+\binom m1+\binom m2 ,
again equal to the Sauer–Shelah bound.
3. Lower bound. Write the labels of 0,e_1,\dots,e_d as y_0,\dots,y_d and let s_i=2y_i-1\in\{\pm1\}. Take b=s_0/2 and w_i=s_i-s_0/2. Then w^\top0+b=s_0/2 and w^\top e_i+b=s_i. Each has the sign s_i and none is zero, so every labelling is produced and d_{\mathrm{VC}}\ge d+1.
Upper bound. Take any d+2 points x_1,\dots,x_{d+2}. The system \sum_i\alpha_ix_i=0, \sum_i\alpha_i=0 has d+1 equations and d+2 unknowns, so it has a solution \alpha\ne0. Because the \alpha_i sum to zero, some are positive and some negative. Let I=\{i:\alpha_i>0\}, let J be the rest, and let s=\sum_{i\in I}\alpha_i>0. Then
p=\sum_{i\in I}\frac{\lambda_i}{s}x_i=\sum_{i\in J}\frac{-\lambda_i}{s}x_i
is a convex combination of the I-points and also of the J-points (Radon’s theorem). Label I by 1 and J by 0. A halfspace producing this labelling would have the convex set \{w^\top x+b\ge0\} contain all I-points, hence p. The convex set \{w^\top x+b<0\} would contain all J-points, hence p too. That is a contradiction. So d_{\mathrm{VC}}=d+1, which for this class equals the number of parameters.
4. Write c_j=1-y_j\in\{0,1\}. Then
\frac{\omega x_i}{\pi}=2^{-i}\Big(1+\sum_{j=1}^mc_j2^j\Big)=\underbrace{\sum_{j>i}c_j2^{j-i}}_{\text{even integer}}+c_i+\theta_i,\qquad \theta_i=\sum_{j<i}c_j2^{j-i}+2^{-i}.
The even integer shifts \omega x_i by a multiple of 2\pi and does not change the sine. Also 0<\theta_i\le\sum_{k=1}^{i-1}2^{-k}+2^{-i}=1-2^{-i}<1. So \omega x_i\equiv\pi(c_i+\theta_i)\pmod{2\pi} with \theta_i\in(0,1), and \sin(\omega x_i)>0 iff c_i=0 iff y_i=1. Every labelling of every finite set \{2^{-1},\dots,2^{-m}\} is produced, so d_{\mathrm{VC}}=\infty. No distribution-free VC bound applies to this one-parameter class.
The number of parameters is neither an upper bound on the VC dimension (this example; ReLU networks with W weights in L layers, whose VC dimension can be of order WL\log(W/L)) nor a lower bound (redundant parameters, as in \mathbf 1[(w_1+w_2)x\ge0], add nothing).
If \omega is a 32-bit float, the class has at most 2^{32} members. Shattering m points needs 2^m distinct functions, so d_{\mathrm{VC}}\le32, and the finite-class bound applies with \ln|\mathcal H|\le32\ln2. The construction above needs \omega/\pi to about m+1 significant bits. The infinite VC dimension comes from the infinite precision of one real number, which can hide arbitrarily many bits. This is the difference between counting parameters and counting bits that the float-encoding bound in 1.1 relies on.
4. Regularization: prior, constraint, filter, flatness
What weight decay, early stopping, dropout and flat minima each do to the learned function, derived exactly in linear models, and why any claim about flatness needs a metric.
Notation: \lambda is the ridge penalty in \frac1n\|y-X\beta\|^2+\lambda\|\beta\|^2 (in 4.2 it is also the KKT multiplier, which turns out to be the same number), a=n\lambda, s_k the singular values of X, \sigma^2 the noise variance, \tau^2 the prior variance, \rho the squared constraint radius in 4.2, t gradient-flow time, q the dropout keep-probability, H the Hessian.
Sharp minima can generalize for deep nets, Laurent Dinh, Razvan Pascanu, Samy Bengio, Yoshua Bengio (ICML 2017)
Rescaling symmetries of ReLU networks make a minimum arbitrarily sharp without changing the function, so weight-space flatness alone cannot explain generalization. Read §2–§4; 4.5.3 is their construction in miniature.
Ridge regression, Wikipedia
The closed form, the Bayesian reading, and the shrinkage of each singular direction; 4.1–4.3 derive all three and compare what they predict.
Early stopping, Wikipedia
Stopping gradient descent before convergence as a regularizer, and its relation to ridge in the spectral picture of 4.3.
Dilution (neural networks), Wikipedia
Dropout and its relatives: what is dropped, how the test-time network is rescaled, and the ensemble reading; 4.4 derives the penalty it adds in a linear model.
Also (techniques not derived here): Tibshirani (1996), the lasso and sparsity; Bishop (1995), training with small input noise equals, to second order in the noise amplitude and for the expected loss, Tikhonov regularization by the input Jacobian (a Hessian term drops out at a minimum); Chen, Dobriban and Lee (2020), data augmentation as averaging over group orbits; Loshchilov and Hutter (2019), decoupled weight decay (AdamW); Ali, Kolter and Tibshirani (2019), the risks of gradient flow and ridge compared along the whole path under t=1/\lambda, the exact version of 4.3.3; Wager, Wang and Liang (2013), dropout in generalized linear models as an L^2 penalty in the diagonal Fisher metric (4.4.3).
For reference (books): Deep Learning, Goodfellow, Bengio and Courville (2016; free online), ch. 7, a survey of every regularizer in common use; The Elements of Statistical Learning, Hastie, Tibshirani and Friedman (2nd ed. 2009; free PDF), §3.4.1–3.4.3.
Exercises: ridge as a prior, a constraint and a filter
Three readings of one penalty, which make different predictions about networks trained on random labels (1.2.2).
Setup for 4.1–4.3. The linear model y=X\beta+\varepsilon has design X\in\mathbb R^{n\times p}, targets y\in\mathbb R^n, and noise \varepsilon of mean 0 and covariance \sigma^2I_n. Ridge regression with penalty \lambda>0 is \hat\beta_\lambda=\arg\min_b\frac1n\|y-Xb\|^2+\lambda\|b\|^2=(X^\top X+n\lambda I)^{-1}X^\top y. The thin SVD is X=\sum_ks_ku_kv_k^\top, with singular values s_k>0 and orthonormal u_k\in\mathbb R^n, v_k\in\mathbb R^p. X^+ is the Moore–Penrose pseudoinverse, so X^+y is the least-squares solution of smallest norm.
4.1. Ridge as a prior: MAP, posterior, and a warning. MAP (maximum a posteriori) is the mode of the posterior density. Take \varepsilon\sim\mathcal N(0,\sigma^2I_n).
- Take the prior \beta\sim\mathcal N(0,\tau^2I) and the likelihood y\mid\beta\sim\mathcal N(X\beta,\sigma^2I). Show that the MAP estimate is ridge with \lambda=\sigma^2/(n\tau^2). Show that the posterior is \mathcal N\big(\hat\beta_\lambda,\ \sigma^2(X^\top X+n\lambda I)^{-1}\big), so the posterior mean equals the MAP here.
- Compare the posterior covariance with the sampling covariance of \hat\beta_\lambda over the noise at fixed \beta, which is \sigma^2(X^\top X+n\lambda I)^{-1}X^\top X(X^\top X+n\lambda I)^{-1} (2.5). Which is larger, and why do they differ?
- MAP depends on the parametrization. Suppose a posterior on \beta>0 has density \pi(\beta)\propto\beta e^{-\beta}. Find its mode. Now write \beta=e^u, find the mode of the density of u, and map it back. Which of the mode, mean and median is invariant under monotone reparametrization? What does this mean for “weight decay is a prior”?
Solution
1. The negative log posterior is \frac1{2\sigma^2}\|y-X\beta\|^2+\frac1{2\tau^2}\|\beta\|^2+\text{const}. Multiplying by 2\sigma^2/n gives \frac1n\|y-X\beta\|^2+\frac{\sigma^2}{n\tau^2}\|\beta\|^2, the ridge objective with \lambda=\sigma^2/(n\tau^2). The log posterior is quadratic in \beta, so the posterior is Gaussian. Its precision is X^\top X/\sigma^2+I/\tau^2=(X^\top X+n\lambda I)/\sigma^2, and its mean (which is also the mode) is \hat\beta_\lambda.
2. Write G=X^\top X and a=n\lambda. The posterior covariance is \sigma^2(G+aI)^{-1} and the sampling covariance is \sigma^2G(G+aI)^{-2}. Their difference is \sigma^2a(G+aI)^{-2}\succeq0, so the posterior is wider. The sampling covariance ignores the bias. The posterior covariance is the bias–variance mean squared error averaged over the prior: along a singular direction v_k of X with singular value s (and \mathbb E\beta_k^2=\tau^2 under the prior), using 2.5.1 at a=\sigma^2/\tau^2,
\frac{a^2\tau^2+\sigma^2s^2}{(s^2+a)^2}=\frac{\sigma^2(a+s^2)}{(s^2+a)^2}=\frac{\sigma^2}{s^2+a}.
3. \frac{d}{d\beta}\log(\beta e^{-\beta})=1/\beta-1=0, so the mode is \beta=1. The density of u=\log\beta is \pi(e^u)e^u\propto e^{2u-e^u}, and \frac{d}{du}(2u-e^u)=0 gives e^u=2, i.e. \beta=2. Same posterior, different “MAP”. The mean is not invariant under nonlinear maps either. The median is invariant under monotone maps.
So the identification “penalty = negative log prior” holds in a chosen parametrization. Weight decay is a Gaussian prior on the weights, which in a network induces some prior on functions that depends on the architecture. The MAP estimate under it is not an invariant summary of the posterior.
4.2. Ridge as a constraint: the Lagrange multiplier. The second reading: minimize the training loss over a ball \|b\|^2\le \rho. Small balls contain few functions, which is the capacity explanation of why regularized models generalize.
- For \rho>0, show that a minimizer of \hat R_n(b)=\frac1n\|y-Xb\|^2 subject to \|b\|^2\le \rho is \hat\beta_\lambda, where \lambda is the KKT (Lagrange) multiplier. Interpret \hat\beta_0=X^+y when the design is rank deficient.
- Show that \rho(\lambda)=\|\hat\beta_\lambda\|^2 is strictly decreasing when X^\top y\neq0. Hence \lambda(\rho) is well defined for \rho<\|X^+y\|^2, and \lambda=0 for \rho\ge\|X^+y\|^2.
- In this view, what explains why the constrained estimator generalizes? Which objection from the random-label experiments (keystone) applies to that explanation?
Hint
For 1, write the Lagrangian \hat R_n(b)+\lambda(\|b\|^2-\rho) with \lambda\ge0, set its gradient to zero, and use complementary slackness. For 2, write \|\hat\beta_\lambda\|^2 in the SVD of X and look at each term as a function of \lambda. For 3, recall 2.1.3; the Rademacher complexity of a norm ball of linear predictors is in Understanding Machine Learning §26.2.
Solution
1. The problem is convex, and Slater’s condition holds for \rho>0. The Lagrangian is \hat R_n(b)+\lambda(\|b\|^2-\rho) with \lambda\ge0. Stationarity gives -\frac2nX^\top(y-Xb)+2\lambda b=0, i.e. b=(X^\top X+n\lambda I)^{-1}X^\top y=\hat\beta_\lambda for \lambda>0. For \lambda=0, use the minimum-norm least-squares solution X^+y; other feasible least-squares solutions may also minimize when X is rank deficient. Complementary slackness says either \lambda=0 (the constraint need not be strictly slack) or \|\hat\beta_\lambda\|^2=\rho.
2. In the SVD, \|\hat\beta_\lambda\|^2=\sum_k\frac{s_k^2(u_k^\top y)^2}{(s_k^2+n\lambda)^2}. Each term is non-increasing in \lambda, and at least one is strictly decreasing when X^\top y\ne0. As \lambda\downarrow0 the norm rises to \|X^+y\|^2, the minimum-norm least-squares solution, and as \lambda\to\infty it falls to 0. So the map from \rho to \lambda is a decreasing bijection on (0,\|X^+y\|^2). Tighter constraints need bigger multipliers.
3. The explanation is capacity. The norm ball \{x\mapsto x^\top b:\|b\|\le B\} has Rademacher complexity of order B\sqrt{\mathbb E\|x\|^2/n} (quoted), which controls prediction complexity. To turn this into a squared-loss gap bound, additionally control the input norms and labels (or suitable tails), so the loss is Lipschitz on the allowed prediction range. Small enough complexity then gives an excess-risk bound via 2.1.3. This inherits two problems. The norm depends on the parametrization (4.1.3, 4.5), and Zhang et al.’s objection applies: nets with weight decay still fit random labels, so the constraint that is actually active is not small.
4.3. Ridge as a spectral filter, and early stopping. The third reading: ridge acts on the principal directions v_k one at a time, keeping the well-determined ones (large s_k) and shrinking the rest. Gradient descent stopped early does something similar. A filter is a set of factors \phi_k\in[0,1] saying how much of each direction an estimator keeps.
- Show that \hat\beta_\lambda=\sum_{k:\,s_k>0}\phi_k\,\dfrac{u_k^\top y}{s_k}\,v_k with \phi_k^{\mathrm{ridge}}=\dfrac{s_k^2}{s_k^2+n\lambda}. The factor (u_k^\top y)/s_k is the unregularized coefficient.
- Run gradient flow \dot\beta=-\nabla L(\beta) on L(\beta)=\frac1{2n}\|X\beta-y\|^2, starting from \beta(0)=0. Show that \beta(t) has the same form with \phi_k^{\mathrm{GF}}(t)=1-e^{-s_k^2t/n}. For gradient descent with step \eta and T steps, show \phi_k=1-(1-\eta s_k^2/n)^T.
- Show that the two filters cross \tfrac12 at the same s^2 if and only if t=\ln2/\lambda. With that matching, write both in terms of x=s^2/(n\lambda), and compare them for x\ll1 and for x\gg1. Which filter passes more of the weak directions? Which shrinks the strong directions more?
- Let p>n. Show that gradient flow from \beta(0)=0 converges to the minimum-norm interpolant X^+y. What is the limit from a nonzero initialization \beta_0?
Hint
Work in the coordinates b_k=v_k^\top\beta, where X^\top X is diagonal and X^\top y=\sum_ks_k(u_k^\top y)v_k; gradient flow then decouples into one scalar linear ODE per k. For 3, set each filter equal to \tfrac12 and solve for s^2. For 4, in which subspace does \dot\beta always lie?
Solution
1. X^\top y=\sum_k s_k(u_k^\top y)v_k and (X^\top X+n\lambda I)^{-1}v_k=v_k/(s_k^2+n\lambda), so \hat\beta_\lambda=\sum_k\frac{s_k(u_k^\top y)}{s_k^2+n\lambda}v_k=\sum_k\frac{s_k^2}{s_k^2+n\lambda}\cdot\frac{u_k^\top y}{s_k}v_k.
2. \nabla L=\frac1n(X^\top X\beta-X^\top y). In coordinates b_k=v_k^\top\beta,
\dot b_k=-\frac{s_k^2}{n}b_k+\frac{s_k}{n}u_k^\top y,
with fixed point (u_k^\top y)/s_k. From b_k(0)=0 the solution is b_k(t)=(1-e^{-s_k^2t/n})(u_k^\top y)/s_k. For gradient descent, b_k^{(T)}-b_k^\infty=(1-\eta s_k^2/n)^T(b_k^{(0)}-b_k^\infty), which gives the stated filter. Directions with s_k=0 never move. Discrete gradient descent converges on the positive eigendirections when 0<\eta<2n/s_{\max}^2; the filter is non-oscillatory for \eta\le n/s_{\max}^2.
3. Ridge equals \tfrac12 at s^2=n\lambda, and flow equals \tfrac12 at s^2t/n=\ln2, i.e. at s^2=n\ln2/t. These coincide iff t=\ln2/\lambda. With this matching, ridge is x/(1+x) and flow is 1-e^{-x\ln2}=1-2^{-x}.
- Weak directions, x\ll1: ridge \approx x and flow \approx x\ln2, so ridge passes about 1/\ln2\approx1.44 times more of each weak direction.
- Strong directions, x\gg1: ridge leaves a shrinkage of 1-\phi\approx1/x, only polynomially small, while flow leaves 2^{-x}, exponentially small. So ridge shrinks the strong directions more.
Gradient flow is the sharper, more step-like filter. The largest disagreements are flow above ridge by about 0.138 (near x\approx4.3) and ridge above flow by about 0.044 (near x\approx0.36). With the naive matching t=1/\lambda, flow becomes 1-e^{-x} and its half-point moves to x=\ln2. “Early stopping is ridge” is right in outline (keep the strong directions, drop the weak ones) and wrong in detail. MDL4 (learning curves) derives how the polynomial tail of the ridge filter affects learning-curve exponents.
4. \dot\beta\in\mathrm{row}(X), so \beta(t)\in\mathrm{row}(X) for all t. For p>n with X of full row rank, all s_k>0 for k\le n, so by 2 the flow converges to \sum_{k\le n}\frac{u_k^\top y}{s_k}v_k=X^+y. That is the unique interpolant in the row space, and so the minimum-norm interpolant. From \beta_0, the row-space component converges to the same place and the null-space component never moves: the limit is X^+y+(I-X^+X)\beta_0. The implicit bias is “minimum distance from the initialization”.
▶ Interactive figure: spectral_filters.html. Use panel A only (panel B belongs to MDL4). Press “match half-points” and read the difference strip: where do the filters disagree, and which passes more of the weak tail? Then set t = 1/λ by hand and see the ln 2 offset.
Exercises: dropout
4.4. Dropout as adaptive L^2. In a linear model, averaging over the dropout noise gives an explicit penalty. Take a linear predictor f(x)=\beta^\top x, training pairs (x_i,y_i) with x_i\in\mathbb R^p the rows of X\in\mathbb R^{n\times p}, and squared loss. Drop inputs independently: \tilde x_{ij}=x_{ij}\xi_{ij}/q with \xi_{ij}\sim\mathrm{Bernoulli}(q), where q is the keep probability; the 1/q keeps \mathbb E\tilde x_{ij}=x_{ij}.
- Show that \mathbb E_\xi\frac1n\sum_i(y_i-\tilde x_i^\top\beta)^2=\frac1n\|y-X\beta\|^2+\frac{1-q}{q}\sum_j\beta_j^2\,\frac{\|x_{\cdot j}\|^2}{n}, where x_{\cdot j} is the j-th column of X.
- Write the penalty as \beta^\top\Gamma\beta. Show that it is invariant under rescaling a feature (x_{\cdot j}\to \alpha x_{\cdot j}, \beta_j\to\beta_j/\alpha), while the ridge penalty is not. Which standard procedure is it equivalent to?
- Take a generalized linear model with per-example loss A(x^\top\beta)-y\,x^\top\beta (for logistic regression, A(\eta)=\log(1+e^\eta)). Expand to second order in the dropout noise and show that the expected penalty is approximately \frac{1-q}{2q}\cdot\frac1n\sum_iA''(x_i^\top\beta)\sum_jx_{ij}^2\beta_j^2. In what sense is this “adaptive”?
Hint
Write \tilde x_i^\top\beta=x_i^\top\beta+\sum_jx_{ij}\beta_j(\xi_{ij}/q-1). The noise has mean zero and \mathrm{Var}(\xi/q)=(1-q)/q.
Solution
1. Let \eta_i=x_i^\top\beta and \delta_i=\tilde x_i^\top\beta-\eta_i=\sum_jx_{ij}\beta_j(\xi_{ij}/q-1). Then \mathbb E\delta_i=0 and, by independence, \mathrm{Var}\,\delta_i=\frac{1-q}{q}\sum_jx_{ij}^2\beta_j^2. So \mathbb E(y_i-\eta_i-\delta_i)^2=(y_i-\eta_i)^2+\mathrm{Var}\,\delta_i. Averaging over i gives the penalty \frac{1-q}{q}\sum_j\beta_j^2\|x_{\cdot j}\|^2/n.
2. \Gamma=\frac{1-q}{q}\,\mathrm{diag}(X^\top X/n). Under x_{\cdot j}\to \alpha x_{\cdot j}, \beta_j\to\beta_j/\alpha, the product \beta_j^2\|x_{\cdot j}\|^2 is unchanged, while ridge’s \beta_j^2 changes by 1/\alpha^2. Dropout on inputs is ridge after standardizing each feature by its root mean square: ridge in the metric \mathrm{diag}(\hat\Sigma).
3. \mathbb E\tilde x_i^\top\beta=\eta_i, so the linear term -y\,\tilde x_i^\top\beta is unchanged in expectation. A second-order expansion gives \mathbb E A(\eta_i+\delta_i)\approx A(\eta_i)+\tfrac12A''(\eta_i)\mathrm{Var}\,\delta_i, so the penalty is \frac1n\sum_i\tfrac12A''(\eta_i)\frac{1-q}{q}\sum_jx_{ij}^2\beta_j^2. For logistic regression A''(\eta)=\hat p(1-\hat p), the Fisher information of the example. The penalty is ridge in the metric of the diagonal Fisher information. Confidently classified examples contribute little, and features that matter on uncertain examples are penalized most. “Adaptive” because the metric depends on the current \beta. For squared loss written as \tfrac12(y-\eta)^2, A''=1, which recovers 1 up to the factor \tfrac12 of that convention.
The general lesson: many “hacky” regularizers are quadratic penalties in disguise, in some metric. The question to ask is “which metric?”
Exercises: flatness
The exact local statement behind “flat minima generalize”, and why the naive version cannot be right.
4.5. Why flatness could matter, and why sharpness needs a metric. Near a minimum \theta^* of the population risk R, write H=\nabla^2R(\theta^*) for the Hessian (large eigenvalues are sharp directions, small ones flat). A trained parameter \hat\theta=\theta^*+\delta is random through the data and the optimizer; write \Sigma=\mathbb E\,\delta\delta^\top for its spread. The per-sample gradient covariance at the optimum is C=\mathrm{Cov}_z[\nabla_\theta\ell(\theta^*;z)], for a loss \ell(\theta;z) on one example z.
- Show that \mathbb E R(\hat\theta)-R(\theta^*)\approx\tfrac12\mathrm{Tr}(H\Sigma). Check that this is exact for least squares with test inputs x\sim\mathcal N(0,I_p), where R(b)=\sigma^2+\|b-\beta\|^2 and \Sigma=\sigma^2(X^\top X)^{-1} (2.2).
- Suppose \hat\theta is ERM in a regular model with \Sigma\approx\frac1nH^{-1}CH^{-1} (the “sandwich” covariance, derived in 7.1). Show that \tfrac12\mathrm{Tr}(H\Sigma)=\frac1{2n}\mathrm{Tr}(H^{-1}C), and that if C=cH this equals cp/(2n), whatever the curvature. What has to be true of \Sigma for “flatter is better” to hold?
- Dinh et al.’s rescaling. Take the two-layer scalar linear network f(x)=w_2w_1x with R(w)=\mathbb E(y-w_2w_1x)^2 and a=\mathbb E x^2>0. Assume c^*=\mathbb E[xy]/a\ne0; the minima are the hyperbola w_1w_2=c^*. Compute the Hessian at a minimum, show that \mathrm{Tr}\,H=2a(w_1^2+w_2^2) and that one eigenvalue is zero. Under (w_1,w_2)\to(\alpha w_1,w_2/\alpha) the function does not change. Show that \mathrm{Tr}\,H takes every value in [4a|c^*|,\infty). Why does the same trick work in deep ReLU networks?
- Let \theta=g(\varphi) be a smooth reparametrization with Jacobian J at the minimum, and let \delta transform as a tangent vector. Show that \mathrm{Tr}(H\Sigma) is invariant while \mathrm{Tr}\,H is not. What does a meaningful flatness claim have to specify?
Hint
For 1, the gradient vanishes at \theta^*, and \mathbb E\,\delta^\top H\delta=\mathrm{Tr}(H\,\mathbb E\,\delta\delta^\top). For 3, write R=a(w_1w_2-c^*)^2+\text{const}. For 4, at a critical point the Hessian transforms as J^\top HJ, because the term involving the second derivative of g multiplies \nabla R=0.
Solution
1. R(\theta^*+\delta)=R(\theta^*)+\nabla R(\theta^*)^\top\delta+\tfrac12\delta^\top H\delta+O(\|\delta\|^3). The gradient term vanishes, and \mathbb E\,\delta^\top H\delta=\mathrm{Tr}(H\Sigma). Here \Sigma is the second moment about \theta^*, so it includes any bias. For OLS, R(b)=\sigma^2+\|b-\beta\|^2 is exactly quadratic with H=2I, and \Sigma=\sigma^2(X^\top X)^{-1}, so \tfrac12\mathrm{Tr}(H\Sigma)=\sigma^2\mathrm{Tr}(X^\top X)^{-1} exactly, as in 2.2.2.
2. \tfrac12\mathrm{Tr}\big(H\cdot\tfrac1nH^{-1}CH^{-1}\big)=\tfrac1{2n}\mathrm{Tr}(CH^{-1}). If C=cH, this is cp/(2n). The curvature cancels: a sharp direction is pinned down more tightly by the data (\Sigma\propto H^{-1}), and this exactly offsets the larger cost of a given error there. “Flatter is better” needs \Sigma that does not shrink in proportion as H grows. One case is a perturbation scale set by something other than the data’s curvature, such as SGD noise at a fixed learning rate: if the gradient noise scales as C\propto H^{g}, 8.2 finds \Sigma\propto H^{g-1} (it writes the exponent as \gamma). So “flat minima generalize” is a claim about H and \Sigma jointly.
3. Write u=w_1w_2, so R=a(u-c^*)^2+\text{const}. Then \partial_{w_1}R=2a(u-c^*)w_2, and at a minimum (u=c^*),
H=2a\begin{pmatrix}w_2^2&w_1w_2\\ w_1w_2&w_1^2\end{pmatrix}=2a\,vv^\top,\qquad v=(w_2,w_1)^\top .
The terms proportional to u-c^* vanish there. So H has rank one, with eigenvalue 2a(w_1^2+w_2^2)=\mathrm{Tr}\,H along v and eigenvalue 0 along (w_1,-w_2), the direction tangent to the hyperbola. Under the rescaling, \mathrm{Tr}\,H=2a(\alpha^2w_1^2+w_2^2/\alpha^2)\ge4a|w_1w_2|=4a|c^*| by AM–GM, with equality at \alpha^2=|w_2/w_1|, and it is unbounded as \alpha\to0 or \infty. Every value in [4a|c^*|,\infty) is attained by the same function. Weight decay would pick the balanced representative. For ReLU networks, \mathrm{ReLU}(\alpha z)=\alpha\,\mathrm{ReLU}(z) for \alpha>0, so multiplying one layer by \alpha and the next by 1/\alpha leaves the network function unchanged. Dinh et al. use this to make any minimum arbitrarily sharp.
4. At a critical point, H_\varphi=J^\top HJ. To first order \delta_\theta=J\delta_\varphi, so \Sigma_\varphi=J^{-1}\Sigma J^{-\top}. Then \mathrm{Tr}(H_\varphi\Sigma_\varphi)=\mathrm{Tr}(J^\top HJJ^{-1}\Sigma J^{-\top})=\mathrm{Tr}(H\Sigma), which is invariant, whereas \mathrm{Tr}\,H_\varphi=\mathrm{Tr}(J^\top HJ) depends on J. A meaningful flatness claim has to say in what metric the perturbations are measured: either the distribution \Sigma of perturbations that actually occurs, or an invariant geometry such as the Fisher (output-space) metric. Raw \mathrm{Tr}\,H in weight space is a property of the parametrization, not of the function.
4.6. What Dinh et al. show. Dinh et al. (reading above) is often cited as “flatness is meaningless”. Using 4.5.4, say precisely what the paper shows and what it leaves open. Name one flatness-like quantity it does not touch.
Solution
The paper shows that weight-space sharpness measures (\mathrm{Tr}\,H, the top eigenvalue, \epsilon-sharpness in a Euclidean ball, flat volume) are not functions of the network function, because a symmetry of the parametrization changes them arbitrarily. So none of them can be a sufficient statistic for generalization, and an empirical correlation between them and test error depends on how parametrizations happen to be distributed in practice. It leaves open quantities that are invariant under the symmetry or carry their own metric:
- \mathrm{Tr}(H\Sigma) with the \Sigma that training actually produces;
- sharpness measured in the Fisher or output-space metric;
- normalized or scale-invariant sharpness;
- the volume of a function-space neighbourhood (the posterior mass of a function), which is what PAC-Bayes and Bayesian accounts use.
It also leaves open whether SGD, from standard initializations, tends to land in parametrizations where raw sharpness happens to track one of these. That is an empirical question about the training procedure, not about the geometry.
5. Interpolation without harm: kernels and benign overfitting
When a fit that passes through every noisy training point is still close to optimal: kernel “ridgeless” regression is a minimum-norm interpolant, and many weak directions act on it as an implicit ridge penalty.
Notation: \lambda is the ridge penalty and a=n\lambda; in 5.1, k(\cdot,\cdot) is the kernel, K the n\times n kernel matrix and s_k the singular values of the feature matrix; in 5.2–5.3, k is the number of signal directions, m the number of tail directions, \nu their variance and c=m\nu the tail’s total variance, which acts as n\lambda; \mu_{\min}(\cdot), \mu_{\max}(\cdot) and \mu_i denote eigenvalues; \sigma^2 is the noise variance and r^2=\|\beta\|^2.
Benign overfitting in linear regression, Peter L. Bartlett, Philip M. Long, Gábor Lugosi, Alexander Tsigler (PNAS, 2020)
Interpolation is near-optimal exactly when the directions unimportant for prediction are many compared with n but small in total variance; 5.2–5.3 is a solvable case. Read §2–§3.
Neural tangent kernel, Wikipedia
A wide network linearized around its initialization trains as kernel regression with the gradient features; in that regime training ends at the ridgeless kernel interpolant of 5.1.
Double descent, Wikipedia
The test-error curve that peaks at the interpolation threshold and falls again; 1.3–1.6 compute it for least squares and 5.2–5.3 say when the right branch is benign.
Also: Jacot, Gabriel and Hongler (2018), the neural tangent kernel paper; Liang and Rakhlin (2020), for high-dimensional inputs the many small eigenvalues of the kernel matrix act as an implicit ridge, the kernel version of 5.2; Lee et al. (2018), wide random networks are Gaussian processes; Rahimi and Recht (2007), random Fourier features; Mei and Montanari (2019), double descent in random-feature regression.
For reference (books): Understanding Machine Learning: From Theory to Algorithms, Shalev-Shwartz and Ben-David (2014; free PDF), ch. 16, §16.1–16.2; Gaussian Processes for Machine Learning, Rasmussen and Williams (2006; free online), ch. 2, §2.1–2.3.
Exercises: kernel ridge regression and the ridgeless limit
5.1. Dual form, representer theorem, ridgeless limit. Training data are (x_1,y_1),\dots,(x_n,y_n) with labels y\in\mathbb R^n. A feature map \phi:\mathcal X\to\mathbb R^D may have D\gg n or D=\infty. The model is f_w(x)=w^\top\phi(x), the feature design \Phi\in\mathbb R^{n\times D} has rows \phi(x_i)^\top, and ridge on the features is \hat w_\lambda=\arg\min_w\frac1n\|y-\Phi w\|^2+\lambda\|w\|^2=(\Phi^\top\Phi+n\lambda I_D)^{-1}\Phi^\top y. The kernel is k(x,x')=\phi(x)^\top\phi(x'), the kernel matrix K=\Phi\Phi^\top has entries k(x_i,x_j), and k_x=\big(k(x,x_1),\dots,k(x,x_n)\big)^\top. The thin SVD is \Phi=\sum_ks_ku_kv_k^\top, so K=\sum_ks_k^2u_ku_k^\top. The Gaussian kernel is k(x,x')=e^{-\|x-x'\|^2/(2\ell^2)}.
- Push-through. For a>0, show that (\Phi^\top\Phi+aI_D)^{-1}\Phi^\top=\Phi^\top(\Phi\Phi^\top+aI_n)^{-1}. Deduce that \hat w_\lambda=\Phi^\top\hat\alpha with \hat\alpha=(K+n\lambda I_n)^{-1}y, and that the prediction at any input x is \hat f_\lambda(x)=\sum_{i=1}^n\hat\alpha_i\,k(x,x_i)=k_x^\top(K+n\lambda I_n)^{-1}y . Suppose each kernel evaluation costs a fixed number of operations. Compare the costs of fitting and of predicting in the primal form (a D\times D solve) and the dual form (an n\times n solve). When is each cheaper?
- Representer theorem. Let \mathcal L:\mathbb R^n\to\mathbb R be any loss that depends on the parameters only through the training predictions \Phi w, and minimize J(w)=\mathcal L(\Phi w)+\lambda\|w\|^2. Show that every minimizer has the form \Phi^\top\alpha for some \alpha\in\mathbb R^n, and rewrite J in terms of \alpha and K only. For the squared loss \mathcal L(v)=\frac1n\|y-v\|^2, check that \hat\alpha from part 1 minimizes the rewritten objective.
- Ridgeless limit. Assume K is invertible. This needs n\le D; for the Gaussian kernel it holds whenever the x_i are distinct. Show that as \lambda\to0, \hat f_\lambda(x)\to k_x^\top K^{-1}y, that this limit interpolates the training data, and that \hat w_0=\Phi^\top K^{-1}y is the minimum-norm interpolant: it minimizes \|w\| subject to \Phi w=y, with \|\hat w_0\|^2=y^\top K^{-1}y.
- What the interpolant pays for. Show that the fitted values and the norm of the fit are \hat y=\Phi\hat w_\lambda=\sum_k\frac{s_k^2}{s_k^2+n\lambda}\,(u_k^\top y)\,u_k,\qquad \|\hat w_\lambda\|^2=\sum_k\frac{s_k^2\,(u_k^\top y)^2}{(s_k^2+n\lambda)^2} . In the setting of part 3, let y_i=f^*(x_i)+\varepsilon_i, where f^*=f_{w^*} and the noise is independent with mean 0 and variance \sigma^2. Show that \mathbb E\|\hat w_0\|^2=\sum_k(v_k^\top w^*)^2+\sigma^2\,\mathrm{Tr}\,K^{-1}. Which part of y makes the interpolant’s norm large when K has tiny eigenvalues, as kernel matrices of smooth kernels do?
Hint
For 1, check that \Phi^\top(\Phi\Phi^\top+aI)=(\Phi^\top\Phi+aI)\Phi^\top, then multiply by inverses on each side. For 2, write w=\Phi^\top\alpha+w_\perp with w_\perp orthogonal to every \phi(x_i), so \Phi w_\perp=0, and use Pythagoras. For 3, any interpolant is \hat w_0+w' with \Phi w'=0; show that w'\perp\hat w_0. For 4, K(K+aI)^{-1}=\sum_k\frac{s_k^2}{s_k^2+a}u_ku_k^\top, and f^* evaluated at the training inputs is \Phi w^*, whose component along u_k is s_k\,v_k^\top w^*.
Solution
1. Both sides of \Phi^\top(\Phi\Phi^\top+aI_n)=\Phi^\top\Phi\Phi^\top+a\Phi^\top=(\Phi^\top\Phi+aI_D)\Phi^\top agree. For a>0 both bracketed matrices are positive definite, hence invertible. Multiplying on the left by (\Phi^\top\Phi+aI_D)^{-1} and on the right by (\Phi\Phi^\top+aI_n)^{-1} gives the identity. With a=n\lambda, \hat w_\lambda=\Phi^\top(K+n\lambda I)^{-1}y=\Phi^\top\hat\alpha, and \hat f_\lambda(x)=\phi(x)^\top\Phi^\top\hat\alpha=k_x^\top\hat\alpha.
Costs, counting arithmetic operations:
| fit | predict one x | |
|---|---|---|
| primal | form \Phi^\top\Phi: O(nD^2); solve: O(D^3) | compute \phi(x), then O(D) |
| dual | form K: O(n^2c); solve: O(n^3) | O(nc) |
The dual form wins when D\gg n, and it is the only option when D=\infty; the primal form wins when n\gg D. For large n the O(n^3) solve and the O(n^2) memory for K are the bottleneck of kernel methods, which is what random features (Rahimi and Recht, in the readings above) address.
2. Split w=w_\parallel+w_\perp, where w_\parallel=\Phi^\top\alpha lies in the span of \phi(x_1),\dots,\phi(x_n) and w_\perp is orthogonal to it. Each entry of \Phi w_\perp is \phi(x_i)^\top w_\perp=0, so \mathcal L(\Phi w)=\mathcal L(\Phi w_\parallel), while \|w\|^2=\|w_\parallel\|^2+\|w_\perp\|^2. Hence J(w)=J(w_\parallel)+\lambda\|w_\perp\|^2, and any w with w_\perp\neq0 is strictly beaten by w_\parallel. Substituting \Phi w=\Phi\Phi^\top\alpha=K\alpha and \|w\|^2=\alpha^\top K\alpha,
J=\mathcal L(K\alpha)+\lambda\,\alpha^\top K\alpha .
The infinite-dimensional problem has become an n-dimensional one that needs only kernel values. The same proof works for any regularizer that is a nondecreasing function of \|w\| (with “a minimizer” in place of “every minimizer” when it is not strictly increasing).
For the squared loss, the gradient in \alpha is -\frac2nK(y-K\alpha)+2\lambda K\alpha=\frac2nK\big[(K+n\lambda I)\alpha-y\big], which vanishes at \hat\alpha. The objective is a convex quadratic in \alpha, so a stationary point is a minimizer. (If K is singular, other minimizers \hat\alpha+v with Kv=0 exist, but \|\Phi^\top v\|^2=v^\top Kv=0, so they all give the same w.)
3. If K is invertible, (K+n\lambda I)^{-1}\to K^{-1}, so \hat f_\lambda(x)\to k_x^\top K^{-1}y. At the training inputs, \Phi\hat w_0=\Phi\Phi^\top K^{-1}y=y, so the limit interpolates. Any other interpolant is \hat w_0+w' with \Phi w'=0, and \hat w_0^\top w'=y^\top K^{-1}\Phi w'=0, so \|\hat w_0+w'\|^2=\|\hat w_0\|^2+\|w'\|^2\ge\|\hat w_0\|^2. Finally \|\hat w_0\|^2=y^\top K^{-1}\Phi\Phi^\top K^{-1}y=y^\top K^{-1}y. In RKHS language: among all functions in \mathcal H_k that fit the data exactly, k_x^\top K^{-1}y has the smallest RKHS norm. Here \hat w_0=\Phi^+y (Moore–Penrose pseudoinverse): the same minimum-norm interpolant that gradient descent from zero finds in linear regression with more parameters than data (4.3.4, 1.4).
4. On the span of the u_k, K(K+aI)^{-1} acts as s_k^2/(s_k^2+a), and it is zero on the orthogonal complement. So \hat y=K\hat\alpha=K(K+n\lambda I)^{-1}y is as stated, and \|\hat w_\lambda\|^2=\hat\alpha^\top K\hat\alpha=\sum_ks_k^2(u_k^\top y)^2/(s_k^2+n\lambda)^2. This is the primal ridge filter of 4.3, as it must be: it is the same estimator.
At \lambda=0, \|\hat w_0\|^2=\sum_k(u_k^\top y)^2/s_k^2. Write y=\Phi w^*+\varepsilon. Since u_k^\top\Phi w^*=s_kv_k^\top w^*, and \mathbb E(u_k^\top\varepsilon)^2=\sigma^2 in every direction,
\mathbb E\|\hat w_0\|^2=\sum_k(v_k^\top w^*)^2+\sigma^2\sum_k\frac1{s_k^2}=\|P_{\rm row}w^*\|^2+\sigma^2\,\mathrm{Tr}\,K^{-1},
where P_{\rm row} projects onto the span of the \phi(x_i). The signal contributes at most \|w^*\|^2, however small the eigenvalues. The noise contributes \sigma^2/s_k^2 per direction, which explodes along the smallest eigenvalues of K: the interpolant fits the noise using exactly the directions the kernel considers least plausible (largest RKHS cost), and pays for it in norm. Ridge suppresses those directions instead. Whether the interpolant’s noise fit actually hurts test error depends on how many small eigenvalues there are and how they spread; that is benign overfitting, 5.2–5.3.
Exercises: benign overfitting
In the isotropic model of 1.4, the minimum-norm interpolant’s excess risk stays bounded away from zero at every fixed p/n>1. Benign overfitting is when an interpolant of noisy labels has excess risk close to the best achievable. Here is an exactly solvable model in which a high-dimensional, low-variance tail of features makes that happen.
Setup for 5.2–5.3.
- Features x=(x_s,x_t), with signal x_s\in\mathbb R^k, x_s\sim\mathcal N(0,I_k), and tail x_t\in\mathbb R^m, x_t\sim\mathcal N(0,\nu I_m), independent of x_s. The tail’s total variance is c=m\nu=\mathbb E\|x_t\|^2.
- Labels y=x_s^\top\beta_s+\varepsilon, with noise \varepsilon\sim\mathcal N(0,\sigma^2) independent of x. The tail carries no signal. Write r^2=\|\beta_s\|^2.
- n i.i.d. samples with k<n<m, stacked as X=[X_s,\,X_t] with X_s\in\mathbb R^{n\times k}, X_t\in\mathbb R^{n\times m}, and labels y\in\mathbb R^n.
- The minimum-norm interpolant is \hat\beta=X^\top(XX^\top)^{-1}y, the \lambda\to0^+ limit of ridge and the limit of gradient descent from 0. Split it as \hat\beta=(\hat\beta_s,\hat\beta_t).
- The excess risk of b=(b_s,b_t) over a fresh x is \mathcal R(b)=\mathbb E\big[(x^\top b-x_s^\top\beta_s)^2\big]=\|b_s-\beta_s\|^2+\nu\|b_t\|^2.
- Ridge on the signal features alone is \hat\beta^{\rm R}_\lambda=(X_s^\top X_s+n\lambda I_k)^{-1}X_s^\top y.
5.2. The tail supplies a ridge penalty.
- Show that \hat\beta_s=X_s^\top(X_sX_s^\top+X_tX_t^\top)^{-1}y and \hat\beta_t=X_t^\top(X_sX_s^\top+X_tX_t^\top)^{-1}y. Prove the push-through identity X_s^\top(X_sX_s^\top+cI_n)^{-1}=(X_s^\top X_s+cI_k)^{-1}X_s^\top for c>0. Conclude that if X_tX_t^\top were exactly cI_n, then \hat\beta_s would be \hat\beta^{\rm R}_\lambda with n\lambda=c.
- Write the columns of X_t as \sqrt\nu\,z_j, j=1,\dots,m, with z_j\sim\mathcal N(0,I_n) i.i.d., so X_tX_t^\top=\nu W with W=\sum_jz_jz_j^\top. Show that \mathbb E\,W/m=I_n, that the diagonal entries of W/m have variance 2/m and the off-diagonal ones 1/m. So X_tX_t^\top\to cI_n entry by entry as m\to\infty at fixed c.
- Entry by entry is not enough, because there are n^2 entries. For a fixed unit vector v\in\mathbb R^n, show that \mathbb E\|(W/m-I_n)v\|^2=(n+1)/m. So W/m moves a typical vector by about \sqrt{n/m}, and X_tX_t^\top\approx cI_n needs m\gg n, not just m large.
- Quoted (Davidson–Szarek; Vershynin’s notes, Corollary 5.35): with probability at least 1-2e^{-t^2/2}, every singular value of the n\times m matrix [z_1,\dots,z_m] lies in [\sqrt m-\sqrt n-t,\ \sqrt m+\sqrt n+t]. With d=\sqrt{n/m}+t/\sqrt m<1, deduce that every eigenvalue of X_tX_t^\top lies in [c(1-d)^2,\ c(1+d)^2], and that the smallest eigenvalue of XX^\top is at least c(1-d)^2. Why does this lower bound matter, given that the variance of the minimum-norm interpolant involves (XX^\top)^{-1}?
Hint
For 1, split X^\top=\begin{pmatrix}X_s^\top\\ X_t^\top\end{pmatrix} and note XX^\top=X_sX_s^\top+X_tX_t^\top. For the identity, start from (X_s^\top X_s+cI_k)X_s^\top=X_s^\top(X_sX_s^\top+cI_n). For 2, (W/m)_{il}=\frac1m\sum_jz_{ij}z_{lj} is an average of m i.i.d. terms; \mathbb Ez^4=3 for a standard normal. For 3, by rotation invariance take v=e_1, so (W/m)v=\frac1m\sum_jz_jz_{1j}. Expand \mathbb E\|(W/m)v\|^2 as a double sum over j,l and separate j=l from j\ne l. For 4, the eigenvalues of X_tX_t^\top are \nu times the squared singular values; X_sX_s^\top\succeq0.
Solution
1. \hat\beta=X^\top(XX^\top)^{-1}y with X^\top=\begin{pmatrix}X_s^\top\\ X_t^\top\end{pmatrix}, so the two blocks are X_s^\top(XX^\top)^{-1}y and X_t^\top(XX^\top)^{-1}y, and XX^\top=X_sX_s^\top+X_tX_t^\top. For the identity, both sides of (X_s^\top X_s+cI_k)X_s^\top=X_s^\top X_sX_s^\top+cX_s^\top=X_s^\top(X_sX_s^\top+cI_n) are equal. Multiply on the left by (X_s^\top X_s+cI_k)^{-1} and on the right by (X_sX_s^\top+cI_n)^{-1}; both inverses exist because c>0. If X_tX_t^\top=cI_n, then \hat\beta_s=X_s^\top(X_sX_s^\top+cI_n)^{-1}y=(X_s^\top X_s+cI_k)^{-1}X_s^\top y=\hat\beta^{\rm R}_{\lambda},\qquad n\lambda=c . The interpolant never sees a penalty. The tail’s Gram matrix plays the role of n\lambda I_n inside the “kernel” form of ridge.
2. \mathbb E\,z_jz_j^\top=I_n, so \mathbb E W/m=I_n. A diagonal entry \frac1m\sum_jz_{ij}^2 has variance \frac1m\mathrm{Var}(z^2)=\frac1m(3-1)=\frac2m. An off-diagonal entry \frac1m\sum_jz_{ij}z_{lj} (i\ne l) has mean 0 and variance \frac1m\mathbb E z_{ij}^2z_{lj}^2=\frac1m. Each entry is an average of m i.i.d. terms, so it converges to the corresponding entry of I_n, and X_tX_t^\top=\nu W=c\,W/m\to cI_n.
3. With v=e_1, (W/m)v=\frac1m\sum_jz_jz_{1j}, and \mathbb E\|(W/m)v\|^2=\frac1{m^2}\sum_{j,l}\mathbb E\big[z_{1j}z_{1l}\,z_j^\top z_l\big]. For j\ne l the factors are independent and \mathbb E[z_{1j}z_j]=e_1, so each of the m(m-1) terms is e_1^\top e_1=1. For j=l, \mathbb E\big[z_{1j}^2\|z_j\|^2\big]=\mathbb Ez_1^4+(n-1)=n+2, for m terms. So \mathbb E\|(W/m)v\|^2=1+(n+1)/m. Since \mathbb E\,v^\top(W/m)v=1, \mathbb E\|(W/m-I)v\|^2=\mathbb E\|(W/m)v\|^2-2\,\mathbb E\,v^\top(W/m)v+1=\frac{n+1}{m}. Summing over v=e_1,\dots,e_n gives \mathbb E\|W/m-I\|_F^2=n(n+1)/m, which matches 2: n\cdot\frac2m+n(n-1)\cdot\frac1m. The individual entries are O(1/\sqrt m), but their effect on a vector adds up over n coordinates. The operator norm \|W/m-I\| is about 2\sqrt{n/m} (part 4), so the approximation X_tX_t^\top\approx cI_n is controlled by n/m.
4. The eigenvalues of W are the squared singular values, so on the stated event they lie in [(\sqrt m-\sqrt n-t)^2,(\sqrt m+\sqrt n+t)^2]=m[(1-d)^2,(1+d)^2]. Multiplying by \nu and using m\nu=c puts the eigenvalues of X_tX_t^\top in [c(1-d)^2,c(1+d)^2]. Since X_sX_s^\top\succeq0, XX^\top\succeq X_tX_t^\top, and so \lambda_{\min}(XX^\top)\ge c(1-d)^2, equivalently \|(XX^\top)^{-1}\|\le1/\big(c(1-d)^2\big). (With n=100, m=20000 the edges are near (1\pm0.07)^2\approx0.86,\,1.15, and a simulation agrees.)
The noise enters the interpolant as X^\top(XX^\top)^{-1}\varepsilon, so its size is governed by the small eigenvalues of XX^\top. In the isotropic model with p\approx n, XX^\top has eigenvalues near zero, and that is where the divergence of the risk at p=n comes from. A high-dimensional tail puts a floor of about c under every eigenvalue of XX^\top, which is exactly what an explicit ridge penalty n\lambda=c does.
5.3. What the memorized noise costs, and when overfitting is benign. Same setup. Write u=(XX^\top)^{-1}y\in\mathbb R^n, so \hat\beta_s=X_s^\top u and \hat\beta_t=X_t^\top u.
- Idealized tail. Suppose X_tX_t^\top=cI_n exactly. Show that u=(y-X_s\hat\beta_s)/c. Deduce that on the training inputs the tail’s predictions X_t\hat\beta_t are exactly the ridge residuals y-X_s\hat\beta^{\rm R}_\lambda (n\lambda=c), and that the tail’s contribution to the test risk is \nu\|\hat\beta_t\|^2=\frac{\|y-X_s\hat\beta^{\rm R}_\lambda\|^2}{m}. Why can the tail reproduce residuals of size \sigma at every training point while contributing so little at a fresh point?
- Real tail. Let \mu_{\min},\mu_{\max} be the extreme eigenvalues of X_tX_t^\top. Show that \nu\|\hat\beta_t\|^2\le\nu\mu_{\max}\|y\|^2/\mu_{\min}^2. Using 5.2.4, conclude that \nu\|\hat\beta_t\|^2\le\frac{\|y\|^2}{m}\cdot\frac{(1+d)^2}{(1-d)^4} with high probability, where d\approx\sqrt{n/m}. With \mathbb E\|y\|^2=n(r^2+\sigma^2), the tail’s cost is O\big((r^2+\sigma^2)\,n/m\big), which tends to 0 as m\to\infty at fixed c.
- Pure-noise tail. Take k=0, so y=\varepsilon\sim\mathcal N(0,\sigma^2I_n) and X=X_t. Using the quoted fact \mathbb E\,W^{-1}=I_n/(m-n-1) for W=\sum_{j=1}^mz_jz_j^\top, z_j\sim\mathcal N(0,I_n) i.i.d., m>n+1, show that \mathbb E\,\nu\|\hat\beta_t\|^2=\sigma^2n/(m-n-1). This does not depend on \nu. What happens as m\downarrow n+1? Is it the small per-coordinate variance \nu, or the dimension m, that makes memorizing noise cheap?
- Assemble. Argue that as m\to\infty at fixed c, \hat\beta_s\to\hat\beta^{\rm R}_\lambda with n\lambda=c, and hence \mathcal R(\hat\beta) tends to the ridge risk \|\hat\beta^{\rm R}_\lambda-\beta_s\|^2, while the training error stays exactly zero. For n\gg k, use X_s^\top X_s\approx nI_k to show that the ridge risk, averaged over the noise, is approximately \frac{c^2r^2+\sigma^2nk}{(n+c)^2}\approx\frac{\sigma^2k}{n}+\frac{c^2r^2}{n^2}\quad(c\ll n). Combine with 1 to write the total excess risk as roughly \sigma^2k/n+c^2r^2/n^2+\sigma^2(n-k)/m. State in words the two conditions under which interpolation is benign, i.e. the excess risk tends to 0 as n\to\infty.
- Contrast with the isotropic model. All p features \mathcal N(0,1) and n<p; the minimum-norm excess risk is \|\beta\|^2(1-n/p)+\sigma^2n/(p-n-1) (1.4, for p>n+1). Think of the features beyond the first few as a tail with \nu=1. Which of the two conditions fails near p\approx n, and which fails for p\gg n? Why can no choice of p satisfy both?
- Effective ranks. For a covariance \Sigma with eigenvalues \mu_1\ge\mu_2\ge\dots, Bartlett et al. define r_j(\Sigma)=\sum_{i>j}\mu_i/\mu_{j+1} and R_j(\Sigma)=\big(\sum_{i>j}\mu_i\big)^2/\sum_{i>j}\mu_i^2, and k^*=\min\{j\ge0:r_j(\Sigma)\ge bn\} for a constant b>1. They call a sequence of problems benign when r_0(\Sigma)/n\to0, k^*/n\to0 and n/R_{k^*}(\Sigma)\to0. Compute these for this model (assume \nu<1, k+c<bn\le m) and check that the three conditions are the ones you found in 4.
Hint
For 1, write out (X_sX_s^\top+cI_n)u=y and recognize X_s^\top u. For the tail cost, \|\hat\beta_t\|^2=u^\top X_tX_t^\top u. For 2, \mu_{\min}(XX^\top)\ge\mu_{\min} because X_sX_s^\top\succeq0, so \|u\|\le\|y\|/\mu_{\min}. For 3, average over \varepsilon first: \mathbb E\,\varepsilon^\top A\varepsilon=\sigma^2\mathrm{Tr}A. For 4, a ridge estimate with X_s^\top X_s=nI_k shrinks each coordinate of the signal-only least-squares estimate (X_s^\top X_s)^{-1}X_s^\top y by n/(n+c); add the squared bias and the variance. For the convergence of \hat\beta_s, write X_tX_t^\top=c(I+\Delta) with \|\Delta\|\to0 and use \|(A+E)^{-1}-A^{-1}\|\le\|A^{-1}\|\,\|E\|\,\|(A+E)^{-1}\|.
Solution
1. u solves (X_sX_s^\top+cI_n)u=y, i.e. cu=y-X_s(X_s^\top u)=y-X_s\hat\beta_s. By 5.2.1, \hat\beta_s=\hat\beta^{\rm R}_\lambda with n\lambda=c. On the training inputs the tail predicts X_t\hat\beta_t=X_tX_t^\top u=cu=y-X_s\hat\beta^{\rm R}_\lambda: the signal block makes the ridge fit, and the tail adds exactly the ridge residual, so the total fit interpolates. The tail’s test cost is \nu\|\hat\beta_t\|^2=\nu\,u^\top X_tX_t^\top u=\nu c\|u\|^2=\frac{\nu}{c}\|y-X_s\hat\beta^{\rm R}_\lambda\|^2=\frac{\|y-X_s\hat\beta^{\rm R}_\lambda\|^2}{m}. For n\gg k, the expected squared ridge residual is about \sigma^2(n-k)+c^2r^2/n (noise the signal block cannot fit, plus the shrinkage bias), so for c\ll n the tail costs about \sigma^2(n-k)/m.
Why it is cheap: \hat\beta_t=\sum_iu_i\,x_{t,i} is a combination of the n training tail vectors. These are nearly orthogonal in \mathbb R^m (here exactly orthogonal, each of squared norm c), so x_{t,i}^\top\hat\beta_t=cu_i reproduces residual i at training point i. A fresh x_t is nearly orthogonal to all of them, and x_t^\top\hat\beta_t has variance \nu\|\hat\beta_t\|^2. The fitted function is the ridge fit plus a narrow spike at each training point, and the spikes occupy a vanishing fraction of the m-dimensional tail.
2. \nu\|\hat\beta_t\|^2=\nu\,u^\top X_tX_t^\top u\le\nu\mu_{\max}\|u\|^2. Because XX^\top\succeq X_tX_t^\top, \mu_{\min}(XX^\top)\ge\mu_{\min}, so \|u\|=\|(XX^\top)^{-1}y\|\le\|y\|/\mu_{\min}. On the event of 5.2.4, \mu_{\min}\ge c(1-d)^2 and \mu_{\max}\le c(1+d)^2, so \nu\|\hat\beta_t\|^2\le\frac{\nu c(1+d)^2}{c^2(1-d)^4}\|y\|^2=\frac{\|y\|^2}{m}\cdot\frac{(1+d)^2}{(1-d)^4}. With \|y\|^2\approx n(r^2+\sigma^2) this is O\big((r^2+\sigma^2)n/m\big). The bound uses \|y\|^2 where 1 had the smaller ridge residual. In simulation (k=5, n=100, m=20000, \sigma=1, r^2=5) the tail cost matches \|y-X_s\hat\beta^{\rm R}_\lambda\|^2/m\approx0.005 to within 1%, against a bound of about 0.05.
3. With k=0, \nu\|\hat\beta_t\|^2=\nu\,\varepsilon^\top(X_tX_t^\top)^{-1}X_tX_t^\top(X_tX_t^\top)^{-1}\varepsilon=\nu\,\varepsilon^\top(\nu W)^{-1}\varepsilon=\varepsilon^\top W^{-1}\varepsilon. Averaging over \varepsilon and then over W, \mathbb E\,\nu\|\hat\beta_t\|^2=\sigma^2\,\mathbb E\,\mathrm{Tr}\,W^{-1}=\frac{\sigma^2n}{m-n-1}. The \nu cancels: rescaling the tail rescales \hat\beta_t inversely, and the test cost is scale-free. As m\downarrow n+1 the cost diverges; this is the double-descent peak again, now inside the tail. For m\gg n it is about \sigma^2n/m. So what makes memorization cheap is the dimension of the tail relative to n. A small \nu is needed for a different reason (part 4): to keep the total c=m\nu, and hence the implicit penalty, small.
4. Write X_tX_t^\top=c(I+\Delta), where \|\Delta\|\le(1+d)^2-1\approx2\sqrt{n/m}\to0, and A=X_sX_s^\top+cI_n\succeq cI_n. Then \hat\beta_s-\hat\beta^{\rm R}_\lambda=X_s^\top\big[(A+c\Delta)^{-1}-A^{-1}\big]y, and \|(A+c\Delta)^{-1}-A^{-1}\|\le\frac1c\cdot c\|\Delta\|\cdot\frac1{c(1-\|\Delta\|)}\to0. So \hat\beta_s\to\hat\beta^{\rm R}_\lambda. With 2, \mathcal R(\hat\beta)=\|\hat\beta_s-\beta_s\|^2+\nu\|\hat\beta_t\|^2\to\|\hat\beta^{\rm R}_\lambda-\beta_s\|^2. The training error is 0 for every m, since \hat\beta interpolates.
Ridge risk: if X_s^\top X_s=nI_k, then \hat\beta^{\rm R}_\lambda=\frac{1}{n+c}X_s^\top y=\frac{n}{n+c}\beta_s+\frac1{n+c}X_s^\top\varepsilon. The bias is -\frac{c}{n+c}\beta_s, and the noise term has covariance \frac{\sigma^2n}{(n+c)^2}I_k. Adding squared bias and variance, \mathbb E_\varepsilon\|\hat\beta^{\rm R}_\lambda-\beta_s\|^2=\frac{c^2r^2+\sigma^2nk}{(n+c)^2}. For c\ll n this is \approx\sigma^2k/n+c^2r^2/n^2. (The fluctuations of X_s^\top X_s around nI_k are of relative size \sqrt{k/n} and change this by a factor 1+O(k/n) on the variance term.) In total, \mathcal R(\hat\beta)\approx\underbrace{\frac{\sigma^2k}{n}}_{\text{signal variance}}+\underbrace{\frac{c^2r^2}{n^2}}_{\text{tail-as-ridge bias}}+\underbrace{\frac{\sigma^2(n-k)}{m}}_{\text{memorized noise}} . In simulation with k=5, n=100, m=20000: for c=10, 0.086 against ridge’s 0.082 (and \sigma^2k/n=0.05); for c=50, both \approx0.62, dominated by the bias. At m=200 (still c=10) the risk is about 1.0, of which 0.92 is the tail term: a tail only twice as wide as n is not benign.
Interpolation is benign (\mathcal R\to0 as n\to\infty) when, besides k\ll n:
- The tail is high-dimensional: m\gg n. The tail then absorbs the noise in nearly orthogonal directions at a cost \approx\sigma^2n/m, and its Gram matrix is close to a multiple of the identity, so it acts as an isotropic ridge.
- The tail is small in total: c=m\nu\ll n, i.e. the implicit penalty \lambda=c/n is small compared with the signal eigenvalue 1. Otherwise the tail-as-ridge over-shrinks the signal.
Both together require \nu\ll n/m\ll1: very many, very weak directions.
5. In the isotropic model every direction has variance 1, so a tail of m\approx p features has c\approx p>n. Near p\approx n the tail is not high-dimensional: \sigma^2n/(p-n-1) is part 3’s formula, and it diverges. For p\gg n the tail is high-dimensional, but its total variance c\approx p\gg n makes the implicit ridge so strong that the fit captures only the fraction n/p of \beta; the risk tends to \|\beta\|^2(1-n/p)\to\|\beta\|^2, the risk of predicting zero. Because \nu=1 is fixed, m\gg n forces c=m\gg n, so the two conditions cannot hold together. (In the isotropic model the signal is also spread over all directions, so this “tail” is not junk; the analogy is about the variance and shrinkage mechanisms, not an exact match.)
6. The eigenvalues are 1 (k times) then \nu (m times). r_0=(k+m\nu)/1=k+c. For j<k, r_j=k-j+c<bn, and r_k=m\nu/\nu=m\ge bn, so k^*=k. Then R_k=(m\nu)^2/(m\nu^2)=m. The benign conditions become (k+c)/n\to0, k/n\to0 and n/m\to0: small tail total (c\ll n), few signal directions, and a high-dimensional tail (m\gg n). Their variance bound \sigma^2(k^*/n+n/R_{k^*})=\sigma^2(k/n+n/m) matches the first and third terms in 4. For a non-isotropic tail, r_k and R_k are the right notions of “how many dimensions the tail effectively has”.
6. PAC-Bayes: bounds for the function you found
A rigorous bound that can be small for the network SGD actually found, because its complexity term depends on the data and the solution rather than on what else the class could fit; it is the one classical bound that survives the keystone’s argument.
Notation: P is the prior, Q the posterior, \mathrm{KL}(Q\|P) their divergence, \delta the confidence level; \lambda>0 is Catoni’s free parameter (Alquier’s notation), not a ridge penalty; \sigma_P^2 is the prior variance, w the trained weights, \hat H the training-loss Hessian.
Computing nonvacuous generalization bounds for deep (stochastic) neural networks with many more parameters than training data, Gintare Karolina Dziugaite, Daniel M. Roy (UAI 2017)
Optimizing a Gaussian posterior around SGD solutions on binary MNIST gives error bounds of 0.16–0.22 for networks with up to 2.4 million parameters, where VC bounds are vacuous by orders of magnitude; on random labels the bound is vacuous. Read §1–3 and §5.
User-friendly introduction to PAC-Bayes bounds, Pierre Alquier (Foundations and Trends in Machine Learning, 2024)
A tutorial whose §2.1 states and proves Catoni’s bound in the notation used here, the bound 6.1 builds in five steps. Read §2.1, then §3.2–3.3 for the Gaussian case of 6.2.
Exercises: a PAC-Bayes bound from scratch
Setup for 6.1–6.2. Examples z are drawn i.i.d. from D; S=(z_1,\dots,z_n). Hypotheses h\in\mathcal H (for a network, a weight vector w\in\mathbb R^p) have a loss \ell(h;z)\in[0,1], risk R(h)=\mathbb E_{z\sim D}\ell(h;z) and empirical risk \hat R_n(h).
- The prior P is a distribution on \mathcal H chosen without looking at S (it may depend on the random initialization).
- The posterior Q is any distribution on \mathcal H, and may depend on S in any way; there is no likelihood and no Bayes rule. A typical choice is \mathcal N(w_{\mathrm{SGD}},\sigma^2I).
- The Gibbs predictor draws a fresh h\sim Q for each prediction; its risk is \mathbb E_QR, its training risk \mathbb E_Q\hat R_n.
- \mathrm{KL}(Q\|P)=\mathbb E_{h\sim Q}\ln\frac{dQ}{dP}(h)\ge0, which is +\infty unless Q is absolutely continuous with respect to P.
Theorem (McAllester’s bound with Maurer’s constants; Alquier §3.2.2, quoted). With probability at least 1-\delta over S, simultaneously for all Q, \mathbb E_QR\le\mathbb E_Q\hat R_n+\sqrt{\frac{\mathrm{KL}(Q\|P)+\ln(2\sqrt n/\delta)}{2n}} . Compare the finite-class bound R(h)\le\hat R_n(h)+\sqrt{(\ln|\mathcal H|+\ln(1/\delta))/(2n)}: the class size has become a divergence of what you chose after seeing the data from what you fixed before. The bound is for the randomized predictor, not for the network at the centre of Q.
6.1. Change of measure, and a PAC-Bayes bound in five steps. Parts 2–3 prove Catoni’s bound (Alquier, Theorem 2.1): for any \lambda>0 fixed before seeing the data, with probability at least 1-\delta, simultaneously for all Q, \mathbb E_QR\le\mathbb E_Q\hat R_n+\frac{\mathrm{KL}(Q\|P)+\ln(1/\delta)}{\lambda}+\frac{\lambda}{8n} .\qquad(\star)
- Donsker–Varadhan. Let f be a bounded function on \mathcal H, and define the Gibbs measure P_f by \frac{dP_f}{dP}=\frac{e^f}{\mathbb E_Pe^f}. Show that for every Q, \mathbb E_Qf\le\mathrm{KL}(Q\|P)+\ln\mathbb E_Pe^f, with equality iff Q=P_f. Equivalently, \ln\mathbb E_Pe^f=\max_Q\big[\mathbb E_Qf-\mathrm{KL}(Q\|P)\big]. What is this for f=-\beta E and P uniform on finitely many states?
- One hypothesis. Fix h and \lambda>0. Use Hoeffding’s lemma (if X\in[a,b] and \mathbb EX=0, then \mathbb Ee^{sX}\le e^{s^2(b-a)^2/8}) to show \mathbb E_S\,e^{\lambda(R(h)-\hat R_n(h))}\le e^{\lambda^2/(8n)}.
- All posteriors at once. Show that with probability at least 1-\delta over S, \mathbb E_{h\sim P}\,e^{\lambda(R(h)-\hat R_n(h))}\le e^{\lambda^2/(8n)}/\delta. Where do you use that P does not depend on S? On this event, apply part 1 with f=\lambda(R-\hat R_n) to obtain (\star) for all Q.
- Choosing \lambda, and the best Q. For fixed Q, minimize the right-hand side of (\star) over \lambda and compare with the theorem above. Why can you not simply plug in the minimizing \lambda, and how does a union bound over a grid of \lambda values fixed in advance repair it? Then, for fixed \lambda, show that the Q minimizing the right-hand side of (\star) is the Gibbs posterior Q_\lambda with \frac{dQ_\lambda}{dP}\propto e^{-\lambda\hat R_n}. When would Q_\lambda be a Bayesian posterior?
- Occam. Let \mathcal H be countable and take Q=\delta_h, the point mass on one hypothesis. Show \mathrm{KL}(\delta_h\|P)=\ln(1/P(h)), and write the bound the theorem gives, which holds for all h simultaneously. What does it give for P uniform on a finite class, and for P(h)\propto2^{-L(h)}, where L(h) is the length in bits of h in a prefix-free code? Why is a point mass useless for real-valued weights under a prior with a density?
Hint
For 1, expand \mathrm{KL}(Q\|P_f)\ge0. For 2, write R(h)-\hat R_n(h)=\frac1n\sum_iX_i with X_i=R(h)-\ell(h;z_i): independent, mean zero, each in an interval of length 1. Take s=\lambda/n. For 3, average part 2 over h\sim P, swap \mathbb E_S and \mathbb E_P, and apply Markov’s inequality to the nonnegative random variable \mathbb E_Pe^{\lambda(R-\hat R_n)}. For 4, use the grid \lambda_k=2^k, k=0,\dots,K-1, with confidence \delta/K for each. For 5, Kraft’s inequality says that the code lengths of a prefix-free binary code satisfy \sum_h2^{-L(h)}\le1.
Solution
1. If \mathrm{KL}(Q\|P)=\infty there is nothing to prove. Otherwise write Z=\mathbb E_Pe^f, so \frac{dQ}{dP_f}=\frac{dQ}{dP}\,Ze^{-f} and
0\le\mathrm{KL}(Q\|P_f)=\mathbb E_Q\Big[\ln\frac{dQ}{dP}-f+\ln Z\Big]=\mathrm{KL}(Q\|P)-\mathbb E_Qf+\ln\mathbb E_Pe^f .
Rearranging gives the inequality, and \mathrm{KL}(Q\|P_f)=0 iff Q=P_f, so the maximum is attained exactly at the Gibbs measure. With P uniform on N states, \mathrm{KL}(Q\|P)=\ln N-\mathrm{Ent}(Q), where \mathrm{Ent}(Q)=-\sum Q\ln Q is the entropy. Taking f=-\beta E gives \mathbb E_Pe^f=Z_\beta/N, with Z_\beta=\sum e^{-\beta E} the partition function. The inequality becomes \langle E\rangle_Q-T\,\mathrm{Ent}(Q)\ge-T\ln Z_\beta=F, with equality for the Boltzmann distribution: the Gibbs variational principle for the free energy.
2. The X_i=R(h)-\ell(h;z_i) are i.i.d., have mean zero, and lie in [R(h)-1,R(h)], an interval of length 1. By independence and Hoeffding’s lemma with s=\lambda/n,
\mathbb E_S\,e^{\lambda(R(h)-\hat R_n(h))}=\prod_{i=1}^n\mathbb E\,e^{(\lambda/n)X_i}\le\big(e^{\lambda^2/(8n^2)}\big)^n=e^{\lambda^2/(8n)} .
3. Average part 2 over h\sim P. Since P is fixed and the integrand is nonnegative, Tonelli’s theorem lets you swap the order: \mathbb E_S\big[\mathbb E_{h\sim P}e^{\lambda(R-\hat R_n)}\big]\le e^{\lambda^2/(8n)}. This is where P must not depend on S. If it did, the inner average would be over a different distribution for each sample, and the swap would no longer reduce to part 2. Markov’s inequality applied to Y=\mathbb E_Pe^{\lambda(R-\hat R_n)}\ge0 gives \Pr_S\big[Y>e^{\lambda^2/(8n)}/\delta\big]\le\delta. On the complementary event, part 1 with f=\lambda(R-\hat R_n) (bounded, since the loss is) gives, for every Q,
\lambda\,\mathbb E_Q(R-\hat R_n)\le\mathrm{KL}(Q\|P)+\ln Y\le\mathrm{KL}(Q\|P)+\frac{\lambda^2}{8n}+\ln\frac1\delta .
Dividing by \lambda gives (\star). The event was defined without reference to Q, which is why the bound holds for all Q at once, including Q chosen using S.
4. Let a=\mathrm{KL}(Q\|P)+\ln(1/\delta). Then a/\lambda+\lambda/(8n) is minimized at \lambda^*=\sqrt{8na}, with value \sqrt{a/(2n)}. This would give \mathbb E_QR\le\mathbb E_Q\hat R_n+\sqrt{(\mathrm{KL}+\ln(1/\delta))/(2n)}, the theorem’s form with \ln(1/\delta) in place of \ln(2\sqrt n/\delta). But \lambda^* depends on \mathrm{KL}(Q\|P), and Q depends on S. The event in part 3 was built for a single \lambda chosen in advance, and nothing covers a \lambda chosen after seeing the data.
Repair. Before seeing the data, fix the grid \lambda_k=2^k, k=0,\dots,K-1, with 2^{K-1}\ge4n, so K\approx\log_2(4n)+1. Apply part 3 to each \lambda_k at confidence \delta/K. By the union bound, with probability at least 1-\delta all K bounds hold at once, for all Q, with \ln(K/\delta) in place of \ln(1/\delta), so you may pick the best k after seeing the data. With a=\mathrm{KL}(Q\|P)+\ln(K/\delta) and whenever the optimized bound is below 1, the optimal \lambda^*=\sqrt{8na} lies in [1,4n], hence within a factor \sqrt2 of a grid point; at \lambda=c\lambda^* the value is \frac12(c+1/c)\sqrt{a/(2n)}, at most 1.061\sqrt{a/(2n)} for c\in[1/\sqrt2,\sqrt2]. The cost is that factor and \ln K\sim\ln\ln n extra nats; the theorem pays \ln(2\sqrt n) instead.
Best Q. Only \mathbb E_Q\hat R_n+\mathrm{KL}(Q\|P)/\lambda depends on Q, and by part 1 with f=-\lambda\hat R_n,
\min_Q\Big[\mathbb E_Q\hat R_n+\frac{\mathrm{KL}(Q\|P)}\lambda\Big]=-\frac1\lambda\ln\mathbb E_Pe^{-\lambda\hat R_n},
attained at Q_\lambda\propto e^{-\lambda\hat R_n}P. If the loss were the negative log-likelihood -\ln p(y\mid x,h) and \lambda=n, then e^{-n\hat R_n}=\prod_ip(y_i\mid x_i,h), and Q_\lambda would be exactly the Bayesian posterior. Other values of \lambda give “tempered” posteriors. The log loss is unbounded, so the [0,1] theorem does not cover that case as stated. The Bayesian posterior is one possible Q among many, and the bound certifies whichever Q you choose.
5. \mathrm{KL}(\delta_h\|P)=1\cdot\ln\frac1{P(h)}, since \delta_h puts all its mass on h. With probability at least 1-\delta, for all h simultaneously,
R(h)\le\hat R_n(h)+\sqrt{\frac{\ln(1/P(h))+\ln(2\sqrt n/\delta)}{2n}} .
- Uniform P on M hypotheses: \ln(1/P(h))=\ln M. This is the finite-class bound, except for \ln(2\sqrt n/\delta) in place of \ln(1/\delta); a direct union bound avoids that extra \ln(2\sqrt n).
- Prefix code: Kraft’s inequality \sum_h2^{-L(h)}\le1 makes P(h)=2^{-L(h)}/Z a distribution with Z\le1, so \ln(1/P(h))\le L(h)\ln2. The complexity is the description length of the particular h you output, L(h)\ln2 nats, regardless of how large the class is. This is the Occam bound: hypotheses with short descriptions need few samples.
- Continuous weights: if P has a density, then P(\{w\})=0 and \mathrm{KL}(\delta_w\|P)=\infty, so the bound is vacuous. To pay a finite price for a real-valued w, either store it to finite precision (a code, as above) or spread Q over a neighbourhood of w whose prior mass is not too small. 6.2 does the second.
6.2. Gaussian posteriors: weight norm and flatness. Take network weights w\in\mathbb R^p, the prior P=\mathcal N(w_0,\sigma_P^2I), with w_0 and \sigma_P fixed before seeing the data (for example w_0=0, or the random initialization), and the posterior Q=\mathcal N(w,\Sigma_Q) centred on the trained weights w. Use Catoni’s bound (\star) from 6.1 with \lambda fixed in advance. For parts 2–4, treat \hat R_n as smooth near w, with Hessian \hat H=\nabla^2\hat R_n(w). This holds for a bounded smooth surrogate loss; for the 0–1 loss these parts are heuristic.
- Show that for Gaussians in \mathbb R^p, \mathrm{KL}\big(\mathcal N(\mu_Q,\Sigma_Q)\,\|\,\mathcal N(\mu_P,\Sigma_P)\big)=\tfrac12\big[\mathrm{tr}(\Sigma_P^{-1}\Sigma_Q)+(\mu_Q-\mu_P)^\top\Sigma_P^{-1}(\mu_Q-\mu_P)-p+\ln\frac{\det\Sigma_P}{\det\Sigma_Q}\big]. Deduce that, with s_1,\dots,s_p the eigenvalues of \Sigma_Q, \mathrm{KL}(Q\|P)=\frac{\|w-w_0\|^2}{2\sigma_P^2}+\frac12\sum_{k=1}^p\Big(\frac{s_k}{\sigma_P^2}-1-\ln\frac{s_k}{\sigma_P^2}\Big). Interpret the two terms. What does the second cost for \Sigma_Q=\sigma_Q^2I with \sigma_Q\ll\sigma_P, and how big is that for p=10^6 and \sigma_P/\sigma_Q=10^3?
- Show that \mathbb E_Q\hat R_n=\hat R_n(w)+\tfrac12\mathrm{tr}(\hat H\Sigma_Q) up to fourth-order terms in the width of Q, whether or not \nabla\hat R_n(w)=0.
- Insert parts 1 and 2 into (\star) and minimize over \Sigma_Q, assuming \hat H\succeq0 and that the quadratic approximation holds over the width of Q. Show that the optimum is \Sigma_Q=(\sigma_P^{-2}I+\lambda\hat H)^{-1} and that the bound becomes \mathbb E_QR\lesssim\hat R_n(w)+\frac1\lambda\Big[\frac{\|w-w_0\|^2}{2\sigma_P^2}+\frac12\ln\det\big(I+\lambda\sigma_P^2\hat H\big)+\ln\frac1\delta\Big]+\frac\lambda{8n}. Which eigendirections of \hat H cost complexity, and how much? Where does weight decay appear?
- The prior picks a metric. Take the two-layer scalar linear network f(x)=w_2w_1x with \hat R_n(w)=a(w_1w_2-c^*)^2+\text{const}, a>0, c^*\ne0 (as in 4.5.3, with the training risk in place of the population risk). Its minima form the hyperbola w_1w_2=c^*; at a minimum \hat H=2a\,vv^\top with v=(w_2,w_1)^\top. The rescaling (w_1,w_2)\to(\alpha w_1,w_2/\alpha) does not change the function. (Illustrative only: the squared loss needs a bounded surrogate, and the quadratic approximation needs \sigma_P\ll|w|.) With w_0=0, show that the norm term and the log-det term of part 3 depend on \alpha only through \rho(\alpha)=\alpha^2w_1^2+w_2^2/\alpha^2, so the bound is smallest at the balanced representative and unbounded as \alpha\to0 or \infty. Is the bound then wrong, or only loose? Show that \mathrm{KL}(Q\|P) is unchanged when the same smooth bijection of weight space is applied to both P and Q. Where did the dependence on the representative come from?
- Random labels. Replace the labels by labels drawn uniformly from 10 classes, independently of x, and use the 0–1 loss. Using the theorem in the setup, show that with probability at least 1-\delta, every Q with \mathbb E_Q\hat R_n\le0.1 has \mathrm{KL}(Q\|P)\ge2n(0.8)^2-\ln(2\sqrt n/\delta). Evaluate this for n=5\times10^4 and \delta=0.05. Why is this consistent with SGD fitting random labels? Why does it not run into the argument of 1.1.3, that every bound depending only on the class, n and \delta must be at least 0.9?
Hint
For 1, take the expectation under Q of \ln q-\ln p, using \mathbb E_Q(x-m)^\top A(x-m)=\mathrm{tr}(A\Sigma_Q)+(\mu_Q-m)^\top A(\mu_Q-m). For 2, expand \hat R_n(w+\varepsilon) with \varepsilon\sim\mathcal N(0,\Sigma_Q); odd moments of \varepsilon vanish. For 3, use \partial_\Sigma\,\mathrm{tr}(A\Sigma)=A and \partial_\Sigma\ln\det\Sigma=\Sigma^{-1}, and simplify with \mathrm{tr}\big(\Sigma_Q(\lambda\hat H+\sigma_P^{-2}I)\big)=p. For 5, what is R(h) for any fixed h?
Solution
1. With \Delta=\mu_Q-\mu_P,
\ln\frac{q(x)}{p(x)}=\frac12\ln\frac{\det\Sigma_P}{\det\Sigma_Q}-\frac12(x-\mu_Q)^\top\Sigma_Q^{-1}(x-\mu_Q)+\frac12(x-\mu_P)^\top\Sigma_P^{-1}(x-\mu_P).
Under Q, the first quadratic form has mean \mathrm{tr}(\Sigma_Q^{-1}\Sigma_Q)=p, and the second has mean \mathrm{tr}(\Sigma_P^{-1}\Sigma_Q)+\Delta^\top\Sigma_P^{-1}\Delta, which gives the formula. With \Sigma_P=\sigma_P^2I, \mathrm{tr}(\Sigma_P^{-1}\Sigma_Q)=\sum_ks_k/\sigma_P^2 and \ln\det\Sigma_P/\det\Sigma_Q=\sum_k\ln(\sigma_P^2/s_k).
- Norm term. \|w-w_0\|^2/(2\sigma_P^2) is an L_2 penalty on the distance travelled from w_0 (see part 3).
- Width term. Each eigendirection costs \frac12\phi(s_k/\sigma_P^2), with \phi(t)=t-1-\ln t\ge0, which is zero iff t=1. Narrowing Q below the prior width costs complexity. For \Sigma_Q=\sigma_Q^2I with \sigma_Q\ll\sigma_P, the cost is about p\ln(\sigma_P/\sigma_Q): roughly the nats needed to specify each of p coordinates to precision \sigma_Q within a range \sigma_P. For p=10^6 and \sigma_P/\sigma_Q=10^3, it is \frac p2(10^{-6}-1+\ln10^6)\approx6.4\times10^6 nats, hopeless for n=5\times10^4.
So a nonvacuous bound needs Q to be about as wide as the prior in almost every direction. In Dziugaite and Roy’s runs, \mathrm{KL}\approx5\times10^3 nats for about 5\times10^5 parameters, roughly 0.01 nats per parameter.
2. Write \varepsilon=w'-w\sim\mathcal N(0,\Sigma_Q). Then \hat R_n(w+\varepsilon)=\hat R_n(w)+\nabla\hat R_n(w)^\top\varepsilon+\frac12\varepsilon^\top\hat H\varepsilon+O(\|\varepsilon\|^3). The linear term has mean zero, whether or not the gradient vanishes, and \mathbb E\,\varepsilon^\top\hat H\varepsilon=\mathrm{tr}(\hat H\Sigma_Q). The cubic term also has mean zero (odd Gaussian moments), so the error is fourth order, and the formula is exact for a quadratic \hat R_n. The randomized predictor pays for curvature in proportion to how widely it spreads. This is where flatness enters.
3. The \Sigma-dependent part of the bound is
J(\Sigma)=\frac12\mathrm{tr}(\hat H\Sigma)+\frac1{2\lambda}\Big[\frac{\mathrm{tr}\,\Sigma}{\sigma_P^2}-p-\ln\det\Sigma+p\ln\sigma_P^2\Big].
It is convex, since -\ln\det is convex. Setting the gradient to zero gives \frac12\hat H+\frac1{2\lambda}(\sigma_P^{-2}I-\Sigma^{-1})=0, so \Sigma_Q^{-1}=\sigma_P^{-2}I+\lambda\hat H. At the optimum, \mathrm{tr}(\hat H\Sigma_Q)+\mathrm{tr}(\Sigma_Q)/(\lambda\sigma_P^2)=\frac1\lambda\mathrm{tr}\big(\Sigma_Q(\lambda\hat H+\sigma_P^{-2}I)\big)=p/\lambda, so
J=\frac p{2\lambda}-\frac p{2\lambda}+\frac1{2\lambda}\ln\det\big(\sigma_P^2\Sigma_Q^{-1}\big)=\frac1{2\lambda}\ln\det\big(I+\lambda\sigma_P^2\hat H\big).
Adding the norm term, \ln(1/\delta)/\lambda and \lambda/(8n) gives the stated bound.
In the eigenbasis of \hat H, with eigenvalues h_k\ge0, the posterior variance is s_k=\sigma_P^2/(1+\lambda\sigma_P^2h_k), and the direction contributes \frac1{2\lambda}\ln(1+\lambda\sigma_P^2h_k) to the bound (its share of the KL plus its curvature penalty, times 1/\lambda).
- Flat directions, h_k\ll1/(\lambda\sigma_P^2): the posterior is as wide as the prior and the contribution is about zero, however many such directions there are.
- Sharp directions: the posterior width is about 1/\sqrt{\lambda h_k} and the contribution about \frac1{2\lambda}\ln(\lambda\sigma_P^2h_k), only logarithmic in the sharpness.
The bound counts the curved directions, not the parameters. This is the PAC-Bayes form of the old minimum-description-length argument that flat minima need fewer bits. Weight decay is the norm term, with w held fixed here. Optimizing w as well trades \hat R_n(w) against \|w-w_0\|^2/(2\lambda\sigma_P^2), which is weight decay towards w_0. Neither \sigma_P nor \lambda may be tuned on the data for free; both need a grid and a union bound, as in 6.1.4. (The Laplace approximation to the Bayesian evidence has the same log-determinant, with n in place of \lambda.)
4. Write \rho(\alpha)=\alpha^2w_1^2+w_2^2/\alpha^2. The norm term is \|w\|^2/(2\sigma_P^2)=\rho(\alpha)/(2\sigma_P^2). At the rescaled point \hat H=2a\,v_\alpha v_\alpha^\top with v_\alpha=(w_2/\alpha,\alpha w_1)^\top. This has rank one with nonzero eigenvalue 2a\|v_\alpha\|^2=2a\rho(\alpha), so \ln\det(I+\lambda\sigma_P^2\hat H)=\ln\big(1+2a\lambda\sigma_P^2\rho(\alpha)\big). Both terms increase with \rho. By AM–GM, \rho\ge2|w_1w_2|=2|c^*|, with equality iff \alpha^2=|w_2/w_1|, the balanced point, and \rho\to\infty as \alpha\to0 or \infty.
Wrong or loose? Every one of these bounds is true, because the theorem holds for all Q at once. They are different numbers for the same function. Since Q may be chosen after seeing the data, you are free to centre it at the balanced representative, so the rescaling cannot make the best available bound worse. Dinh et al.’s construction (sharp minima, same function) shows only that the representative SGD lands on need not be the one that gives the best bound.
Invariance. If \varphi is a smooth bijection and P'=\varphi_\#P, Q'=\varphi_\#Q, both densities pick up the same Jacobian factor, which cancels in q'/p', so \mathrm{KL}(Q'\|P')=\mathrm{KL}(Q\|P). The dependence on the representative came from choosing isotropic Gaussians in the w coordinates: an isotropic Gaussian in rescaled coordinates is a different prior, which favours different representatives. Choosing P is choosing a metric, and so a notion of “flat”, which is the requirement 4.5.4 found for any meaningful flatness claim. Because the loss depends on w only through the function f_w, the theorem applies equally to distributions over functions, and by the data-processing inequality their KL is no larger than the weight-space KL. Weight-space KL overcharges by paying to specify which of many equivalent w you hold (Dziugaite and Roy, Appendix B).
5. For any fixed h, \Pr[h(x)\ne y]=0.9, because y is uniform on 10 classes and independent of x, hence of h(x). So \mathbb E_QR=0.9 for every Q. On the theorem’s event, 0.9\le\mathbb E_Q\hat R_n+\sqrt{(\mathrm{KL}+\ln(2\sqrt n/\delta))/(2n)}. If \mathbb E_Q\hat R_n\le0.1, then \mathrm{KL}(Q\|P)\ge2n(0.8)^2-\ln(2\sqrt n/\delta). For n=5\times10^4 and \delta=0.05, \ln(2\sqrt n/\delta)\approx9.1, so \mathrm{KL}\ge6.4\times10^4 nats, about 1.3 nats per training example.
This is consistent with fitting random labels. SGD finds w with \hat R_n(w)=0, but every Q that keeps the Gibbs training error below 0.1 must be far from P: narrow around a sharp memorizing solution, or far from w_0, or both. The theorem predicts its own vacuity on such data. On real labels nothing forbids a small KL. Dziugaite and Roy found Q with \mathrm{KL}\approx5\text{–}9\times10^3 nats at n=55{,}000, and nonvacuous bounds. Their random-label run (two classes) ended at \mathrm{KL}\approx2\times10^5, with a bound of 1.35.
The argument of 1.1.3 applies to bounds of the form \epsilon(n,\delta) that depend only on the class, n and \delta. Such a bound must also hold on the random-label distribution, so it is at least 0.9. The PAC-Bayes right-hand side also depends on S through Q and \mathbb E_Q\hat R_n. It can be large on random labels and small on real ones, with the same prior, architecture and n. What the bound does not explain is why SGD on real data lands near wide, low-KL regions. It certifies that when it happens; it does not predict it.
7. Bayes and MLE generalization error
In the classical regime the expected excess risk of a fitted model is \mathrm{Tr}(H^{-1}C)/2n, built from a curvature matrix and a gradient-noise matrix; this section derives it, the model-selection criteria it implies (TIC, AIC, BIC), and how a single fit compares with the Bayes ensemble. Most claims of the form “count the parameters”, “flat minima generalize” or “the posterior is what matters” are claims about this formula.
Notation: H is the curvature (Hessian of the population risk at its minimizer \theta^*) and C the covariance of the per-sample gradient there, p the number of parameters, n the sample size, \sigma^2 the noise variance; in 7.5 \lambda is the real log canonical threshold, not a ridge penalty.
Akaike information criterion, Wikipedia
The criterion, its derivation as an estimate of expected out-of-sample log-likelihood, and its relation to BIC and cross-validation; 7.2–7.4 derive it from the sandwich.
Also: Bayesian information criterion (Wikipedia) and Schwarz (1978), BIC; the sandwich is due to Huber (1967) and, for misspecified likelihoods, White (1982); Watanabe (2010), the Bayes generalization error and WAIC in singular models, where the parameter count p/2 is replaced by the real log canonical threshold (7.5.2).
For reference (books): The Elements of Statistical Learning, Hastie, Tibshirani and Friedman (2nd ed. 2009; free PDF), §7.4–7.5, §7.7.
Exercises: the sandwich, TIC and AIC
Setup for 7.1–7.6. Loss \ell(\theta;z) for parameters \theta\in\mathbb R^p; population risk R(\theta)=\mathbb E_z\ell(\theta;z) with minimizer \theta^*; empirical risk \hat R_n on n i.i.d. examples; ERM \hat\theta_n=\arg\min\hat R_n. The curvature is H=\nabla^2R(\theta^*). The gradient noise is C=\mathrm{Cov}_z[\nabla\ell(\theta^*;z)]=\mathbb E\big[\nabla\ell(\theta^*;z)\nabla\ell(\theta^*;z)^\top\big], since the mean gradient vanishes at \theta^*. The optimism is the expected generalization gap \mathbb E[R(\hat\theta_n)-\hat R_n(\hat\theta_n)]; the excess risk is \mathbb E R(\hat\theta_n)-R(\theta^*). A parameter \theta^*+\delta with \mathbb E\delta\delta^\top=\Sigma has excess risk \approx\tfrac12\mathrm{Tr}(H\Sigma) (4.5.1).
Regular regime: p fixed and n\to\infty; \theta^* unique and interior; H\succ0; \hat\theta_n\to\theta^*; enough smoothness and moments for Taylor expansions, the law of large numbers and the CLT. Networks are not regular: they have flat directions from symmetries (singular models; singular learning theory, SLT, is the extension).
Loss conventions: squared loss here is \ell=\tfrac12(y-f_\theta(x))^2 (2.2 used (y-f)^2, which doubles \mathrm{Tr}(H^{-1}C)). For the log loss \ell=-\log p_\theta(y\mid x), ERM is maximum likelihood (MLE), and for a well-specified model (data generated by p_{\theta^*}) the excess risk is \mathbb E_x\mathrm{KL}(p_{\theta^*}\|p_\theta), in nats.
7.1. The sandwich: asymptotic normality of ERM. Starting from the first-order condition \nabla\hat R_n(\hat\theta_n)=0, show that \sqrt n\,(\hat\theta_n-\theta^*)\ \Rightarrow\ \mathcal N\big(0,\ H^{-1}CH^{-1}\big). Classical maximum-likelihood theory says instead that the MLE’s covariance is approximately I^{-1}/n, with the Fisher information I=\mathbb E\big[\nabla\log p_\theta\,\nabla\log p_\theta^\top\big]=-\mathbb E\,\nabla^2\log p_\theta (the two forms agree for a well-specified model; 7.4). Which of H and C does that formula use, and when does it give the wrong answer?
Hint
Taylor-expand \nabla\hat R_n around \theta^*. Apply the law of large numbers to \nabla^2\hat R_n(\theta^*) and the central limit theorem to \sqrt n\,\nabla\hat R_n(\theta^*), then Slutsky’s lemma (if A_n\to A in probability and b_n\Rightarrow b, then A_nb_n\Rightarrow Ab).
Solution
Expanding, 0=\nabla\hat R_n(\hat\theta_n)=\nabla\hat R_n(\theta^*)+\nabla^2\hat R_n(\tilde\theta)\,(\hat\theta_n-\theta^*) for some \tilde\theta between \hat\theta_n and \theta^* (row by row). So \sqrt n(\hat\theta_n-\theta^*)=-\big[\nabla^2\hat R_n(\tilde\theta)\big]^{-1}\sqrt n\,\nabla\hat R_n(\theta^*). \nabla\hat R_n(\theta^*)=\frac1n\sum_i\nabla\ell(\theta^*;z_i) is an average of i.i.d. vectors with mean 0 and covariance C, so by the CLT \sqrt n\,\nabla\hat R_n(\theta^*)\Rightarrow\mathcal N(0,C). By the LLN and consistency, \nabla^2\hat R_n(\tilde\theta)\to H in probability. By Slutsky, the limit is -H^{-1}\mathcal N(0,C)=\mathcal N(0,H^{-1}CH^{-1}). This is the sandwich, with H^{-1} as the bread and C as the filling (Huber; White 1982 for misspecified likelihoods).
The “inverse Fisher information” formula is H^{-1} (or C^{-1}; for the log loss, C is the score form of I and H the Hessian form), which equals the sandwich only when C=H (7.4). Misspecification can break this equality, although it need not do so in every model. Example: heteroscedastic noise fitted with a homoscedastic model, as in 7.3.
7.2. Excess risk, optimism, and a factor of two.
- Show that \mathbb E\,R(\hat\theta_n)-R(\theta^*)\approx\frac1{2n}\mathrm{Tr}(H^{-1}C).
- Show that the expected optimism is twice as large: \mathbb E\big[R(\hat\theta_n)-\hat R_n(\hat\theta_n)\big]\approx\frac1n\mathrm{Tr}(H^{-1}C). This is Takeuchi’s information criterion (TIC): estimate the test loss by \hat R_n(\hat\theta_n)+\frac1n\mathrm{Tr}(\hat H^{-1}\hat C), where \hat H and \hat C are the training-set averages of \nabla^2\ell and of \nabla\ell\,\nabla\ell^\top at \hat\theta_n.
- Explain the factor of two in one sentence. Which of the two quantities does a held-out set estimate?
Hint
For 2, expand \hat R_n around its own minimizer \hat\theta_n and evaluate the expansion at \theta^*. Then use \mathbb E\hat R_n(\theta^*)=R(\theta^*).
7.3. A misspecified case where parameter counting is off by 3. Let x\sim\mathcal N(0,1) and y=\beta x+\varepsilon, where \varepsilon\mid x\sim\mathcal N(0,\sigma^2x^2): the noise is heteroscedastic. Fit y\approx\theta x with \ell=\tfrac12(y-\theta x)^2.
- Compute H, C, the asymptotic variance of \hat\theta_n, the expected excess risk and the expected optimism.
- Compare each with what you get by assuming homoscedastic noise of the same average variance, \mathbb E\varepsilon^2=\sigma^2, i.e. with C=\sigma^2H. By what factor is the naive answer wrong?
Hint
At \theta^*=\beta the per-sample gradient is -\varepsilon x. For a standard normal, \mathbb E x^4=3.
Solution
7.2.1. By 7.1, \delta=\hat\theta_n-\theta^* has \mathbb E\,\delta\delta^\top\approx\Sigma_n:=H^{-1}CH^{-1}/n. By the 4.5 formula, the expected excess risk is \tfrac12\mathrm{Tr}(H\Sigma_n)=\frac1{2n}\mathrm{Tr}(HH^{-1}CH^{-1})=\frac1{2n}\mathrm{Tr}(H^{-1}C).
7.2.2. Expand \hat R_n around its minimizer, where its gradient vanishes: \hat R_n(\theta^*)\approx\hat R_n(\hat\theta_n)+\tfrac12\delta^\top\hat H\delta, with \hat H=\nabla^2\hat R_n\approx H. Take expectations, using \mathbb E\hat R_n(\theta^*)=R(\theta^*) because \theta^* does not depend on the sample: \mathbb E\hat R_n(\hat\theta_n)\approx R(\theta^*)-\tfrac1{2n}\mathrm{Tr}(H^{-1}C). Subtracting this from 1 gives \mathbb E[R(\hat\theta_n)-\hat R_n(\hat\theta_n)]\approx\big(\tfrac1{2n}+\tfrac1{2n}\big)\mathrm{Tr}(H^{-1}C)=\frac1n\mathrm{Tr}(H^{-1}C).
7.2.3. The test loss of \hat\theta_n is above R(\theta^*) by \mathrm{Tr}(H^{-1}C)/2n, and its training loss is below R(\theta^*) by the same amount, because \hat\theta_n was fitted to that sample’s noise. The optimism spans both. A held-out set estimates R(\hat\theta_n), so held-out minus training loss estimates the optimism. Held-out loss cannot give the excess risk without the unknown R(\theta^*), although differences of excess risk between two models are measurable.
7.3.1. \nabla\ell=-(y-\theta x)x, so H=\mathbb E x^2=1. At \theta^*=\beta, \nabla\ell=-\varepsilon x, so C=\mathbb E[\varepsilon^2x^2]=\mathbb E[\sigma^2x^2\cdot x^2]=3\sigma^2, using \mathbb E x^4=3. Hence:
- \mathrm{Var}\,\hat\theta_n\approx H^{-1}CH^{-1}/n=3\sigma^2/n;
- excess risk \approx\mathrm{Tr}(H^{-1}C)/2n=3\sigma^2/2n;
- optimism \approx3\sigma^2/n.
7.3.2. The homoscedastic formulas use C=\sigma^2H, i.e. \mathrm{Tr}(H^{-1}C)=\sigma^2p with p=1. They give variance \sigma^2/n, excess risk \sigma^2/2n and optimism \sigma^2/n: all too small by a factor of 3. The noise is largest exactly where x is large, which is where the data have the most leverage on \hat\theta.
Numerical check (checks/wb2b_check.py): for a model misspecified in both mean and noise (y=\sin2x+(0.3+0.5|x|)\xi fitted linearly with an intercept), \mathrm{Tr}(H^{-1}C)=3.19 while the naive \sigma^2p=2.01. At n=200, over 2\times10^4 replications, the excess risk is 0.00812 against the formula’s 0.00799, and the optimism 0.01608 against 0.01597, a ratio of 1.98. The same check for a misspecified logistic regression (a non-quadratic loss, n=400) gives a ratio of 1.98.
7.4. When C=H: the Fisher identity and AIC. For a probabilistic model trained with the log loss on data it generated, gradient noise equals curvature, and every parameter costs the same.
- Let \ell(\theta;x,y)=-\log p_\theta(y\mid x), with the data generated by p_{\theta^*}. Prove that C=H at \theta^* by differentiating \int p_\theta(y\mid x)\,dy=1 twice.
- Conclude that the optimism is p/n and the excess risk p/2n. Relate this to Akaike’s criterion, AIC =-2\log L(\hat\theta)+2p, where \log L=-n\hat R_n is the log-likelihood.
- For squared loss \ell=\tfrac12(y-f_\theta(x))^2 with y=f_{\theta^*}(x)+\varepsilon, \varepsilon independent of x and of variance \sigma^2, show that C=\sigma^2H, so \mathrm{Tr}(H^{-1}C)=\sigma^2p. Check this against the exact least-squares result of 2.3 (excess risk \sigma^2p/(n-p-1) in the (y-f)^2 convention), minding the factor of two.
Solution
1. Write s=\nabla_\theta\log p_\theta (the score). Differentiating \int p_\theta\,dy=1 once gives 0=\int\nabla p_\theta=\int p_\theta\,s, so \mathbb E_{p_\theta}s=0. Differentiating again gives 0=\int\nabla^2p_\theta=\int p_\theta\big(\nabla^2\log p_\theta+ss^\top\big), using \nabla^2p/p=\nabla^2\log p+ss^\top. So \mathbb E_{p_\theta}[ss^\top]=-\mathbb E_{p_\theta}[\nabla^2\log p_\theta]. At \theta=\theta^* the data come from p_{\theta^*}, so averaging also over x gives C=\mathbb E[ss^\top]=\mathbb E[\nabla^2\ell]=H.
2. \mathrm{Tr}(H^{-1}C)=\mathrm{Tr}(I_p)=p. So the optimism is p/n and the excess risk, which here is the KL to the truth, is p/2n nats per sample. Estimating the expected test log loss by \hat R_n(\hat\theta_n)+p/n and multiplying by 2n gives -2\log L(\hat\theta)+2p: AIC is TIC with C=H assumed. This is “parameter counting”, and it is exact only for well-specified regular models.
3. \nabla\ell=-r\nabla f with r=y-f_\theta(x), and \nabla^2\ell=\nabla f\nabla f^\top-r\nabla^2f. At \theta^*, r=\varepsilon. So C=\mathbb E[\varepsilon^2\nabla f\nabla f^\top]=\sigma^2\mathbb E[\nabla f\nabla f^\top] by independence, and H=\mathbb E[\nabla f\nabla f^\top]-\mathbb E[\varepsilon\nabla^2f]=\mathbb E[\nabla f\nabla f^\top] since \mathbb E[\varepsilon\mid x]=0. Hence C=\sigma^2H.
For OLS with x\sim\mathcal N(0,I), this predicts excess risk \sigma^2p/2n in the \tfrac12 convention, i.e. \sigma^2p/n in 2.3’s (y-f)^2 convention. That matches the large-n limit of 2.3’s exact \sigma^2p/(n-p-1).
Exercises: the Bayesian side
7.5. Laplace and BIC. A Bayesian compares models by their evidence. Take the log loss, so the likelihood of the training set is L(\theta)=e^{-n\hat R_n(\theta)}, a prior density \pi continuous and positive at \theta^*, and the evidence Z_n=\int\pi(\theta)\,e^{-n\hat R_n(\theta)}\,d\theta. The Laplace approximation Taylor-expands \hat R_n to second order around \hat\theta_n, with Hessian \hat H=\nabla^2\hat R_n(\hat\theta_n), and integrates the Gaussian exactly.
- Show that -\log Z_n=n\hat R_n(\hat\theta_n)+\frac p2\log n+\tfrac12\log\det\hat H-\frac p2\log2\pi-\log\pi(\hat\theta_n)+o(1). Hence -2\log Z_n=-2\log L(\hat\theta_n)+p\log n+O(1): the Bayesian (Schwarz) information criterion, BIC.
- AIC’s penalty is 2p and BIC’s is p\log n. Which question does each answer?
Solution
1. Near \hat\theta_n, n\hat R_n(\theta)\approx n\hat R_n(\hat\theta_n)+\frac n2(\theta-\hat\theta_n)^\top\hat H(\theta-\hat\theta_n), and \pi(\theta)\approx\pi(\hat\theta_n) over the region of width O(n^{-1/2}) that dominates the integral. The Gaussian integral gives Z_n\approx\pi(\hat\theta_n)\,e^{-n\hat R_n(\hat\theta_n)}\,(2\pi)^{p/2}\det(n\hat H)^{-1/2}, and \det(n\hat H)=n^p\det\hat H. Taking -\log gives the stated expansion. Every term except the first two is O(1), so -2\log Z_n=-2\log L(\hat\theta_n)+p\log n+O(1).
2. AIC (and TIC) estimate the expected test loss of the plug-in predictor p_{\hat\theta_n}: a prediction question. BIC approximates -2\log of the evidence, so differences of BIC approximate log posterior odds between models: a model-identification question. The evidence penalizes each parameter by \tfrac12\log n because the posterior volume shrinks like n^{-p/2} relative to the prior (the Occam factor; MDL3, Occam and prior volume). In singular models this volume scaling changes: \frac p2\log n becomes \lambda\log n with \lambda the real log canonical threshold (RLCT), the central quantity of singular learning theory (SLT). (This \lambda is not a ridge penalty.) In one sentence: with K(\theta)=R(\theta)-R(\theta^*), the prior mass of near-optimal parameters scales as \int_{K(\theta)<\epsilon}\pi(\theta)\,d\theta\propto\epsilon^{\lambda} as \epsilon\to0 (up to a power of \log(1/\epsilon)). In a regular model that set is an ellipsoid \tfrac12\delta^\top H\delta<\epsilon in p dimensions, with mass \propto\epsilon^{p/2}, so \lambda=p/2. Degenerate (flat) directions make the set fatter, which makes \lambda smaller than p/2.
7.6. Bayes versus MLE generalization error. “The generalization error” of a Bayesian learner can mean three things. Use the log loss, a model p_\theta(y\mid x) and a truth q(y\mid x), well specified, q=p_{\theta^*}. The posterior is \pi_n(\theta)\propto\pi(\theta)\prod_ip_\theta(y_i\mid x_i) and the posterior predictive (the Bayes ensemble) is \bar p_n(y\mid x)=\int p_\theta(y\mid x)\,\pi_n(d\theta). With \mathbb E_D over the training sample:
- Single fit (MLE): \mathcal E=\mathbb E_D\,\mathbb E_x\,\mathrm{KL}\big(q\,\|\,p_{\hat\theta_n}\big).
- Bayes generalization error: B_g=\mathbb E_D\,\mathbb E_x\,\mathrm{KL}\big(q\,\|\,\bar p_n\big).
- Gibbs generalization error (one posterior draw): G_g=\mathbb E_D\,\mathbb E_{\theta\sim\pi_n}\,\mathbb E_x\,\mathrm{KL}\big(q\,\|\,p_\theta\big).
Watanabe (Mathematical Theory of Bayesian Statistics, 2018, ch. 1–2) shows that for a regular model \mathbb E\,B_g=\frac p{2n}+o(\frac1n) and \mathbb E\,G_g=\frac pn+o(\frac1n), and that under the assumptions of singular learning theory \mathbb E\,B_g=\frac\lambda n+o(\frac1n), with the real log canonical threshold \lambda\le p/2 of 7.5 in place of p/2.
- Show that B_g\le G_g always.
- In the regular case, approximate the posterior by \mathcal N\big(\hat\theta_n,(nH)^{-1}\big). Show that G_g\approx p/n.
- Show that B_g\approx p/2n, the same as \mathcal E to leading order.
- Without well-specification, define K^*=\mathbb E_x\mathrm{KL}(q\|p_{\theta^*}). Keep the same Laplace posterior and compute G_g-K^* in terms of \mathrm{Tr}(H^{-1}C). What does this say about the posterior’s width?
Hint
For 1, \mathrm{KL}(q\|\cdot) is convex in its second argument. For 2, write a posterior draw as \theta=\hat\theta_n+u, with \mathbb E[u\mid D]=0 and \delta=\hat\theta_n-\theta^* fixed given the data. For 3, expand \log\mathbb E_u\,p_{\hat\theta_n+u}(y\mid x) to second order in u, and use the Fisher identity of 7.4.
Solution
1. \bar p_n=\mathbb E_{\theta\sim\pi_n}p_\theta, and \mathrm{KL}(q\|\cdot) is convex, so by Jensen \mathrm{KL}(q\|\bar p_n)\le\mathbb E_{\theta\sim\pi_n}\mathrm{KL}(q\|p_\theta). Average over x and D.
2. For a draw \theta=\theta^*+\delta+u, the excess risk is \approx\tfrac12(\delta+u)^\top H(\delta+u). Given the data, u has mean zero, so the cross term vanishes in expectation, and G_g\approx\tfrac12\mathrm{Tr}\Big(H\big(\mathbb E\delta\delta^\top+\mathbb Euu^\top\big)\Big) =\tfrac12\mathrm{Tr}\big(H(H^{-1}/n+H^{-1}/n)\big)=\frac pn, using \mathbb E\delta\delta^\top=H^{-1}CH^{-1}/n=H^{-1}/n (since C=H). The draw pays the ERM’s error once and the posterior’s own spread once more.
3. Write \ell=-\log p_\theta, g=\nabla\ell(\hat\theta_n) and h=\nabla^2\ell(\hat\theta_n) at a given (x,y). Then \log\bar p_n=\log\mathbb E_u\,e^{-\ell(\hat\theta_n+u)} \approx-\ell(\hat\theta_n)+\log\mathbb E_u\,e^{-u^\top g-\frac12u^\top hu} \approx-\ell(\hat\theta_n)+\tfrac12\mathbb E_u\big[u^\top(gg^\top-h)u\big], to order 1/n, since \mathbb E u=0. With \mathbb Euu^\top=(nH)^{-1}, the correction is \frac1{2n}\mathrm{Tr}\big(H^{-1}(gg^\top-h)\big). Averaging over (x,y)\sim q near \theta^*, \mathbb E[gg^\top-h]=C-H=0 by the Fisher identity. So -\mathbb E\log\bar p_n=R(\hat\theta_n)+o(1/n), and B_g\approx\mathcal E\approx p/2n.
In the regular case the ensemble buys nothing at leading order. The three estimands differ by constant factors (\tfrac12,\tfrac12,1 times p/n). In singular models they come apart: B_g\approx\lambda/n, while these regular-case arguments do not determine the MLE’s leading error.
Numerical check (checks/wb2b_check.py), with linear-Gaussian regression, p=5, n=100, known noise and a flat prior, so that the posterior is exactly Gaussian: \mathcal E=0.0268 (exact finite-n value p/2(n-p-1)=0.0266), B_g=0.0258, G_g=0.0526, against p/2n=0.025 and p/n=0.05.
4. Now \mathbb E\delta\delta^\top=H^{-1}CH^{-1}/n while the posterior still has covariance H^{-1}/n, so G_g-K^*\approx\frac1{2n}\big(\mathrm{Tr}(H^{-1}C)+p\big). The approximation error K^* need not vanish under misspecification. The posterior’s width is set by H alone, but the actual sampling spread of \hat\theta_n is set by the sandwich. A misspecified posterior is overconfident when C\succ H and underconfident when C\prec H. This is one honest motivation for tempering.
8. Gradient noise, curvature, and generalization measures
For trained networks the gradient noise C is not proportional to the curvature H, so the clean cancellations of §7 fail; this decides what SGD’s noise cloud looks like (not a posterior) and which published complexity measures can track the generalization gap.
Notation: H and C as in §7, \eta the learning rate, B the batch size, \Sigma the stationary covariance of the iterates, T a temperature, \mu_{\max}(H) the largest eigenvalue of H; in 8.2, C=cH^\gamma with a scalar c and an exponent \gamma (neither is the c or \gamma of earlier sections); Kendall’s \tau in 8.4 is a rank correlation.
Fantastic generalization measures and where to find them, Yiding Jiang, Behnam Neyshabur, Hossein Mobahi, Dilip Krishnan, Samy Bengio (ICLR 2020)
Over 40 complexity measures ranked against the generalization gap across thousands of CIFAR-10 networks trained to the same cross-entropy. Norm-based measures often fail or anti-correlate; sharpness and PAC-Bayes measures do best. Read §2 and §4.
On the superlinear relationship between SGD noise covariance and loss landscape curvature, Yikuan Zhang, Ning Yang, Yuhai Tu (arXiv, 2026)
Why C ∝ H fails for networks (compare 8.1), and per-layer power laws C_ii ∝ H_ii^γ with fitted γ near 1–1.5. Read §2 and §4–5; note which layers the fits cover.
Stochastic gradient descent as approximate Bayesian inference, Stephan Mandt, Matthew D. Hoffman, David M. Blei (JMLR, 2017)
Constant-step SGD near a minimum as an Ornstein–Uhlenbeck process, and how to tune it so its stationary law approximates a posterior; the analysis behind 8.2.
Also: Hänni and Vaintrob, A circuit prior in NN-Bayes (LessWrong, 2026), a sample-complexity result for Bayesian learning with networks, not for SGD (see 8.2.7).
Exercises: does curvature cancel? Gradient noise, curvature and SGD
Setup for 8.1–8.3. Loss \ell(\theta;z), population risk R, minimizer \theta^* (shifted to 0 where convenient), curvature H=\nabla^2R(\theta^*), gradient-noise covariance C=\mathrm{Cov}_z[\nabla\ell(\theta;z)]. A parameter \theta^*+\delta with \mathbb E\,\delta\delta^\top=\Sigma has excess risk \approx\tfrac12\mathrm{Tr}(H\Sigma) (4.5.1); for ERM in the regular regime \Sigma\approx H^{-1}CH^{-1}/n (7.1). A tempered posterior at temperature T is \pi_T(\theta)\propto\pi(\theta)\,e^{-n\hat R_n(\theta)/T}; near a nondegenerate mode it is approximately \mathcal N\big(\theta^*,\frac TnH^{-1}\big), long in flat directions and narrow in sharp ones.
8.1. Same pieces, different weights. Here both matrices are empirical: averages over the n training examples at the current parameter.
- Squared loss. Let \ell_i=\tfrac12r_i^2 with residual r_i=f_\theta(x_i)-y_i, and v_i=\nabla f_\theta(x_i). Write the per-sample gradient g_i and the per-sample Gauss–Newton matrix h_i (the Hessian without the r_i\nabla^2f term). Show that h_i has rank at most one, and that over the training set H_{GN}=\frac1n\sum_ih_i,\qquad C=\frac1n\sum_ir_i^2h_i-\bar g\bar g^\top , where \bar g=\frac1n\sum_ig_i is the full-batch gradient and C is the empirical covariance of the g_i.
- At an interpolating minimum (r_i=0 for all i), what are C and H_{GN}? Away from interpolation, under what condition is C=\sigma^2H_{GN}?
- Logistic loss. With y_i\in\{0,1\}, s_i=\sigma(f_\theta(x_i)), where \sigma(t)=1/(1+e^{-t}), and \ell_i=-y_i\log s_i-(1-y_i)\log(1-s_i), show that g_i=(s_i-y_i)v_i and that the per-sample Gauss–Newton matrix is h_i=a_iv_iv_i^\top with a_i=s_i(1-s_i). For a correctly classified example with large margin, compare the weights of v_iv_i^\top in g_ig_i^\top and in h_i. Which goes to zero faster as the margin grows?
Solution
1. g_i=\nabla\ell_i=r_iv_i and \nabla^2\ell_i=v_iv_i^\top+r_i\nabla^2f, so h_i=v_iv_i^\top, which has rank at most one (rank one when v_i\ne0). Averaging gives H_{GN}. The empirical gradient covariance is \frac1n\sum_ig_ig_i^\top-\bar g\bar g^\top=\frac1n\sum_ir_i^2v_iv_i^\top-\bar g\bar g^\top.
2. At interpolation every r_i=0, so every g_i=0 and C=0. But H_{GN}=\frac1n\sum v_iv_i^\top\neq0. So C\propto H fails completely: gradient noise vanishes in every direction while curvature does not. Away from interpolation, at the population optimum with r=-\varepsilon independent of x (hence of v) and \mathbb E\varepsilon=0: \bar g=0 and C=\mathbb E[\varepsilon^2]\,\mathbb E[vv^\top]=\sigma^2H_{GN}. The cancellation needs noise that is independent of where you are in input space, i.e. a well-specified model with homoscedastic noise.
3. \partial\ell_i/\partial f=s_i-y_i, so g_i=(s_i-y_i)v_i, and \partial^2\ell_i/\partial f^2=s_i(1-s_i), giving h_i=a_iv_iv_i^\top. For y_i=1 with margin f\to\infty: g_ig_i^\top has weight (1-s_i)^2\approx e^{-2f}, and h_i has weight a_i\approx e^{-f}. So g_ig_i^\top\approx a_i^2v_iv_i^\top: the noise weight is the square of the curvature weight. Both vanish as the network separates the data, but the noise vanishes faster, so C/H\to0 again. (If y were resampled from the model, \mathbb E_y(s-y)^2=s(1-s)=a and C=H: the Fisher identity. The mismatch comes from using the observed labels, which the model fits.)
8.2. SGD’s stationary law on a quadratic basin, and the posterior. With a constant learning rate, SGD settles into a stationary cloud around a minimum rather than converging. Near the minimum (shifted to 0), take R(\theta)\approx\tfrac12\theta^\top H\theta with H\succ0, and SGD with learning rate \eta and batch size B: \theta_{k+1}=\theta_k-\eta\,(H\theta_k+\xi_k),\qquad\mathbb E\,\xi_k=0,\quad\mathrm{Cov}\,\xi_k=C/B, with \xi_k independent across steps and of \theta_k, and C fixed near the minimum. Assume 0<\eta<2/\mu_{\max}(H). The stationary covariance \Sigma is the covariance of \theta_k once it no longer changes from step to step. A Lyapunov equation is a linear matrix equation A\Sigma+\Sigma A^\top=Q for symmetric \Sigma; an Ornstein–Uhlenbeck (OU) process is d\theta=-A\theta\,dt+Q^{1/2}dW. Measured networks have diagonal power laws C_{ii}\propto H_{ii}^\gamma with \gamma roughly 1–1.5 (Zhang, Yang and Tu); \gamma=1 is C\propto H, and \gamma=0 is noise that ignores curvature.
- Show that the stationary covariance of the recursion satisfies \Sigma_\eta=(I-\eta H)\Sigma_\eta(I-\eta H)+\eta^2C/B, and that to leading order in \eta this is the Lyapunov equation H\Sigma+\Sigma H=\frac\eta B\,C . (It is also the stationary equation of the OU process d\theta=-H\theta\,dt+\sqrt{\eta/B}\,C^{1/2}dW, with t=\eta k.)
- Show that the Lyapunov equation has a unique solution for H\succ0. If C and H commute, show that \Sigma=\frac\eta{2B}CH^{-1}. With C=cH^\gamma, this is \Sigma=\frac{\eta c}{2B}H^{\gamma-1}.
- Show that \Sigma=\frac TnH^{-1} for some temperature T if and only if C\propto I. Do not assume that C and H commute. Find T.
- Show that \tfrac12\mathrm{Tr}(H\Sigma)=\frac{\eta\,\mathrm{Tr}\,C}{4B} exactly, for any C.
- With C=cH^\gamma, write three excess risks: ERM’s \frac1{2n}\mathrm{Tr}(H^{-1}C) from 7.2, SGD’s stationary value, and the tempered posterior’s \tfrac12\mathrm{Tr}(H\cdot\frac TnH^{-1}). What does each count?
- Preconditioning. Replace the update by \theta\leftarrow\theta-\eta P(H\theta+\xi) with P\succ0. Write the new Lyapunov equation. Assuming C\succ0, show that P=C^{-1} gives \Sigma=\frac\eta{2B}H^{-1}.
- For \gamma\in[1,2], compare the shapes of \Sigma and the posterior: along which directions does SGD spread more than the posterior? What would “SGD is approximately Bayesian” have to mean?
Hint
For 2, \Sigma=\int_0^\infty e^{-Ht}\,\frac\eta BC\,e^{-Ht}dt solves the equation; for uniqueness, work in H’s eigenbasis, where the equation reads (h_j+h_k)\Sigma_{jk}=\frac\eta BC_{jk}. For 3, substitute \Sigma=\kappa H^{-1}. For 4, take the trace.
Solution
1. \theta_k is independent of \xi_k, so \mathrm{Cov}\,\theta_{k+1}=(I-\eta H)\,\mathrm{Cov}\,\theta_k\,(I-\eta H)+\eta^2C/B. At stationarity, expanding gives \Sigma_\eta=\Sigma_\eta-\eta(H\Sigma_\eta+\Sigma_\eta H)+\eta^2H\Sigma_\eta H+\eta^2C/B, i.e. H\Sigma_\eta+\Sigma_\eta H=\frac\eta BC+\eta H\Sigma_\eta H. Since \Sigma_\eta=O(\eta), the last term is O(\eta^2); dropping it gives the Lyapunov equation. (Along an eigendirection of curvature h, the discrete law is wider by a relative O(\eta h), and diverges at \eta h\ge2.)
2. In the eigenbasis of H (eigenvalues h_j>0), the equation reads (h_j+h_k)\Sigma_{jk}=\frac\eta BC_{jk}, which has the unique solution \Sigma_{jk}=\frac\eta B\,C_{jk}/(h_j+h_k). If C commutes with H, C is diagonal in the same basis, so \Sigma_{jj}=\frac\eta{2B}C_{jj}/h_j, i.e. \Sigma=\frac\eta{2B}CH^{-1}. With C=cH^\gamma, \Sigma=\frac{\eta c}{2B}H^{\gamma-1}.
3. If \Sigma=\kappa H^{-1}, then H\Sigma+\Sigma H=2\kappa I, so \frac\eta BC=2\kappa I and C\propto I. Conversely, if C=cI then \Sigma=\frac{\eta c}{2B}H^{-1} solves the equation, and by uniqueness it is the solution. No commutation was assumed. Matching \frac{\eta c}{2B}=\frac Tn gives T=\frac{n\eta c}{2B}.
4. Take the trace of the Lyapunov equation: \mathrm{Tr}(H\Sigma)+\mathrm{Tr}(\Sigma H)=2\,\mathrm{Tr}(H\Sigma)=\frac\eta B\mathrm{Tr}\,C. So \tfrac12\mathrm{Tr}(H\Sigma)=\frac{\eta\,\mathrm{Tr}\,C}{4B}, for any C, commuting or not.
5. With C=cH^\gamma:
| excess risk | counts | |
|---|---|---|
| ERM (7.2) | \frac c{2n}\mathrm{Tr}\,H^{\gamma-1} | sampling noise in \hat\theta_n, each direction weighted by noise over curvature |
| SGD stationary | \frac{\eta c}{4B}\mathrm{Tr}\,H^\gamma | total gradient noise per step; curvature does not enter separately |
| posterior | \frac{Tp}{2n} | parameter count at temperature T; neither H nor C enters |
At \gamma=1 (the Fisher case), ERM gives \frac{cp}{2n}, parameter counting, while SGD gives \frac{\eta c}{4B}\mathrm{Tr}H, which grows with sharpness. For this \gamma=1 comparison at fixed c, the SGD excess-risk value increases with curvature. This local calculation does not by itself determine how SGD selects between basins. Its noise scale is \eta/B, not 1/n.
6. The update is \theta\leftarrow(I-\eta PH)\theta-\eta P\xi. The same calculation gives PH\Sigma+\Sigma HP=\frac\eta BPCP. With P=C^{-1}, try \Sigma=\kappa H^{-1}: the left side is 2\kappa C^{-1} and the right side is \frac\eta BC^{-1}, so \kappa=\frac\eta{2B}. Preconditioning by the inverse noise covariance makes the continuous-time stationary covariance posterior-shaped when C\succ0. With Gaussian diffusion this also matches the Gaussian stationary law; covariance matching alone does not establish a Gaussian law for arbitrary discrete update noise. This is the idea behind using preconditioned SGD as an approximate posterior sampler.
7. With \gamma\in[1,2], \Sigma\propto H^{\gamma-1} ranges from isotropic (\gamma=1) to \propto H (\gamma=2). The posterior \propto H^{-1} is long in flat directions and narrow in sharp ones. SGD’s cloud is at least as wide in sharp directions as in flat ones: the opposite ordering. “SGD samples a (tempered) posterior” is the claim that \gamma\approx0, i.e. isotropic gradient noise, or that one has preconditioned by C^{-1}. Neither holds for plain SGD in the measured regime.
8.3. A two-dimensional example. Take H=\mathrm{diag}(1,10): \theta_1 is flat and \theta_2 sharp. With gradient noise C=cH^\gamma, SGD’s stationary covariance is \Sigma=\frac{\eta c}{2B}H^{\gamma-1} (8.2.2) and the posterior’s is \frac TnH^{-1}. Find the axes and aspect ratio of SGD’s \Sigma for \gamma=0,1,2, and compare each with the posterior. Which way does each SGD ellipse point? What happens if C’s eigenbasis is rotated relative to H’s? The interactive figure below draws these ellipses.
Solution
- \gamma=0: \Sigma\propto H^{-1}, elongated along the flat \theta_1 with aspect ratio \sqrt{10} in standard deviations. Same shape as the posterior.
- \gamma=1: \Sigma=\frac{\eta c}{2B}I, a circle.
- \gamma=2: \Sigma\propto H, elongated along the sharp \theta_2: rotated 90° from the posterior.
- Rotating C’s eigenbasis tilts \Sigma off the axes. Since \Sigma\propto H^{-1} requires C\propto I (8.2.3), no temperature fixes the shape, and \mathrm{KL}^*>0 for every T.
- The discrete-time ellipse is slightly wider than the continuous one along \theta_2, by a relative O(\eta h_2)=O(10\eta), where h_2=10 is the sharp curvature.
This is as far as MDL1 goes. The Training Dynamics materials take up state-dependent noise, edge-of-stability effects and what happens away from a quadratic basin.
▶ Interactive figure: sgd_stationary_vs_posterior.html. Slide γ from 0 to 2 and watch the SGD ellipse rotate from the posterior’s shape through a circle to the opposite orientation. Then rotate the noise (φ) and check that no temperature recovers the posterior shape. The readout panel shows ½Tr(HΣ) = ηTr C/4B, T*, and the discrete-time correction.
Exercises: fantastic generalization measures
8.4. Invariance, and the assumptions behind TIC. Jiang et al. (reading above) rank complexity measures by how well they predict the generalization gap. TIC estimates that gap as \frac1n\mathrm{Tr}(H^{-1}C) (7.2), assuming the regular regime.
- Let \theta=A\phi with A invertible be a reparametrization that leaves the network function fixed (or the linearization of a smooth one at the minimum). Show that at the minimum H\to A^\top HA and C\to A^\top CA, and that \mathrm{Tr}(H^{-1}C) is invariant. Which of the parameter \ell_2 norm, the gradient variance \mathrm{Tr}\,C, \mathrm{Tr}\,H and the product of layer spectral norms are invariant under the layer rescaling of 4.5.3, and which under a general A?
- Jiang et al. train every model to the same cross-entropy. Why? Using 8.1, what does this do to the per-sample gradients and to \hat C? Which assumptions behind the derivation of TIC in 7.2 fail for these networks?
- Jiang et al. score each measure by rank correlation with the gap. Kendall’s \tau (a rank correlation, unrelated to the prior variance \tau^2 of earlier sections) over a set of models is the fraction of pairs of models that the measure and the gap order the same way, minus the fraction they order oppositely. The pooled \tau uses all pairs of models. The granulated \Psi (their §2.2) computes \tau only over pairs that differ in a single hyperparameter, then averages over hyperparameters. Why might a measure have a high pooled \tau but a low \Psi?
Hint
For 1, per-sample gradients transform as \nabla_\phi\ell=A^\top\nabla_\theta\ell, and at a critical point the Hessian transforms as in 4.5.4. For 2, list the assumptions of the regular regime (fixed p with n\to\infty, H\succ0, the trained parameter is the ERM) and check each.
Solution
1. Under a reparametrization \theta=A\phi with A invertible (or its linearization, for a smooth one) that leaves the function fixed, gradients transform as \nabla_\phi=A^\top\nabla_\theta, so H\to A^\top HA and C\to A^\top CA at the minimum. Then \mathrm{Tr}(H^{-1}C)\to\mathrm{Tr}(A^{-1}H^{-1}A^{-\top}A^\top CA)=\mathrm{Tr}(H^{-1}C): TIC is invariant. (More generally, the eigenvalues of H^{-1}C are.)
- Not invariant: the parameter \ell_2 norm, the raw gradient variance \mathrm{Tr}\,C, and plain sharpness (\mathrm{Tr}\,H or a worst-case perturbation of fixed size).
- Invariant to the layer rescaling of 4.5.3 but not to general reparametrizations: the product of layer spectral norms, since \|\alpha W_1\|\,\|W_2/\alpha\|=\|W_1\|\,\|W_2\| in a ReLU network.
- Functions of the function: the margin, and the gap itself.
2. Fixing the training loss removes a trivial predictor: models with higher training loss have a different gap for uninteresting reasons. The price is that every model is near interpolation, where per-sample gradients are small (8.1). \hat C is then small and dominated by the hardest examples, and the regular-case theory behind \mathrm{Tr}(H^{-1}C) is furthest from applying. The assumptions that fail:
- Interpolation (8.1): at exact squared-loss interpolation, the empirical \hat C is zero even though population gradient variability and test loss can remain positive. Plug-in TIC then loses its regular-regime justification. Jiang et al. stop at a small positive cross-entropy, not exact interpolation; for cross-entropy both curvature and gradient covariance can shrink, at different rates.
- Singular H: overparametrized networks have flat directions, so H^{-1} is undefined and damped versions depend on \epsilon. The regular-case p/2 becomes the RLCT (7.5–7.6), which TIC does not see.
- SGD is not ERM: the trained parameter’s spread is the stationary law of 8.2, set by \eta/B and \mathrm{Tr}\,C, not the sandwich. Learning-rate and batch-size axes move the gap through a channel TIC does not model. (\mathrm{Tr}\,C itself does model it, which is one reading of Jiang et al.’s gradient-variance result.)
- Wrong loss: TIC is about the training loss. The 0–1 gap can move while the cross-entropy optimism does not, and conversely.
- Ensembles: TIC is about a single fitted network. If what you report is an ensemble’s error, the leading constant can change (7.6).
Where the assumptions do roughly hold (p small compared with n, a nondegenerate minimum, training loss bounded away from zero, a trained parameter close to the ERM), comparisons within one architecture across data size or regularization strength are the natural use of TIC.
3. If one hyperparameter (say, width) moves both the measure and the gap strongly, the pooled \tau is high even if the measure tracks nothing within any fixed setting of the others. \Psi only counts comparisons where one hyperparameter changes, so a measure that just tracks one axis scores well on that axis and near zero on the others. A measure that predicts along one axis and not another is tracking the axis, not the gap.
9. Did deep networks compress? The information bottleneck
A once-popular account said networks generalize because SGD compresses what their layers keep about the input; the debate that followed is a compact lesson in what mutual information can and cannot measure about a deterministic network.
Notation: X is the input, T=f(X) a layer’s activations, I(X;T) their mutual information, q_\Delta a discretization of T with bin width \Delta and K bins.
Information bottleneck method, Wikipedia
The objective (keep what T says about Y, forget the rest of X), its rate–distortion form, and the deep-learning claims built on it; 9.1 shows what it means for a deterministic layer.
Opening the black box of deep neural networks via information, Ravid Shwartz-Ziv, Naftali Tishby (arXiv, 2017)
The claim: in the information plane, training has a short fitting phase and a long compression phase driven by SGD noise. Read it against 9.1–9.2.
On the information bottleneck theory of deep learning, Andrew M. Saxe, Yamini Bansal, Joel Dapello, Madhu Advani, Artemy Kolchinsky, Brendan D. Tracey, David D. Cox (ICLR 2018)
The critique: compression appears with saturating tanh units but not ReLU, non-compressing networks generalize, and full-batch training shows the same curves.
Information Theory of Deep Learning, Naftali Tishby (talk, 2017; YouTube)
Tishby’s own account of the information plane and the compression claim, given before the critiques; watch it knowing what 9.1–9.2 show.
Also: Tishby, Pereira and Bialek (1999), the information bottleneck as rate–distortion with a learned distortion; Goldfeld et al. (2019), add a little noise to each layer and I(X;T) becomes finite, and its decrease is then the clustering of same-class representations.
For reference (books): Elements of Information Theory, 2nd ed., Cover and Thomas (2006), ch. 2; ch. 10, §10.1–10.3.
Exercises: what the information plane measures
Setup for 9.1–9.2. X is the network input, Y the label, and T=f(X) the activations of one hidden layer, a deterministic function of X. The information plane plots each layer as \big(I(X;T),\,I(T;Y)\big) during training; moving left is “compression”. For discrete variables, H(X)=-\sum p\log p, I(X;T)=H(T)-H(T\mid X), and the data-processing inequality says that if X\to T\to T' is a Markov chain (e.g. T' a function of T), then I(X;T')\le I(X;T). Quantizing a variable with density g to bins of small width \delta gives entropy h-\log\delta+o(1), where h=-\int g\log g is its differential entropy. Shwartz-Ziv and Tishby estimated I(X;T) by binning a \tanh network’s activations into 30 equal bins on [-1,1], with X uniform over 4096 inputs.
9.1. A deterministic network has nothing to compress.
- Let X be discrete and T=f(X) for a deterministic f. Show that I(X;T)=H(T), and that I(X;T)=H(X) if f is injective on the support of X.
- In Shwartz-Ziv and Tishby’s setup, X is uniform over 4096 inputs. What is I(X;T) for any layer that maps distinct inputs to distinct activation vectors? With 32-bit floats, can two distinct inputs still be mapped to exactly the same activation vector, and what would cause it?
- Now let X have a density on \mathbb R^d, and suppose T=f(X) has an atomless distribution, i.e. \Pr[T=t]=0 for every t (true, for example, if f is smooth and injective). Show that I(X;T)=\infty.
- Conclude: which changes to the weights can change I(X;T) in cases 1 and 3?
Hint
For 3, let q_\Delta quantize T to cubes of side \Delta. Since q_\Delta(T) is a function of X, part 1 and data processing give I(X;T)\ge I(X;q_\Delta(T))=H(q_\Delta(T)). Then use H(Q)\ge-\log\max_k\Pr[Q=k].
Solution
1. I(X;T)=H(T)-H(T\mid X), and H(T\mid X)=0 because T is determined by X. So I(X;T)=H(T)=H(f(X)). If f is injective on the support, f(X) is a relabelling of X, so H(f(X))=H(X).
2. H(X)=\log4096=12 bits \approx8.32 nats, for every such layer, at every step of training, as long as the layer stays injective on the 4096 inputs. Exact collisions are possible but need a mechanism: units that are exactly zero on whole regions of input (dead ReLUs), or saturated \tanh units that round to exactly \pm1 in floating point, can map distinct inputs to the same vector. Without such collisions, nothing in I(X;T) changes, whatever a binned estimate does.
3. Let q_\Delta map T to the cube of side \Delta that contains it. q_\Delta(T) is a deterministic function of X, so by 1, I(X;q_\Delta(T))=H(q_\Delta(T)). Since X\to T\to q_\Delta(T), data processing gives I(X;T)\ge H(q_\Delta(T))\ge-\log\max_k\Pr[q_\Delta(T)=k].
It remains to show that m(\Delta):=\sup_{\text{cubes }Q\text{ of side }\Delta}\Pr[T\in Q]\to0. Suppose not: then there are \epsilon>0 and cubes Q_j with sides \Delta_j\to0 and \Pr[T\in Q_j]\ge\epsilon. By tightness, the Q_j eventually lie in a compact set, so a subsequence of their centres converges to some t_0. Every ball around t_0 then has probability at least \epsilon, so \Pr[T=t_0]\ge\epsilon, contradicting atomlessness. Hence H(q_\Delta(T))\to\infty and I(X;T)=\infty.
(Equivalently, when T has a density, h(T\mid X)=-\infty because T given X is a point mass.)
4. In case 3, none: I(X;T)=\infty for every weight setting that keeps T atomless. In case 1, only exact collisions, where two distinct inputs are mapped to exactly the same activation vector, can lower H(f(X)). Such collisions are possible, for example with dead ReLUs. The constancy conclusion requires injectivity on the discrete input support; the infinite-information conclusion requires atomlessness. Under those conditions, movement in a finite plotted estimate does not describe a change in the exact mutual information.
9.2. What the binned estimator measures: saturation looks like compression. The binned estimator replaces T by its bin index \mathrm{bin}(T) and reports I(X;\mathrm{bin}(T)), which by 9.1.1 is just H(\mathrm{bin}(T)). Take one unit with standard normal pre-activation Z and pre-activation scale a>0, the weight norm. Training typically grows a.
- T=\tanh(aZ), binned into K equal bins on [-1,1], with K even. Show that H(\mathrm{bin}(T))\to\log2 as a\to\infty. What is the limit as a\to0? How does it change if K is odd?
- Sketch H(\mathrm{bin}(T)) as a function of a for K=30. Explain why steadily growing weights alone produce a “fitting phase” followed by a “compression phase”.
- T=\mathrm{ReLU}(aZ)=\max(0,aZ), binned with a fixed width \Delta: [0,\Delta),[\Delta,2\Delta),\dots. Show that as a\to\infty, H(\mathrm{bin}(T))=\log2+\tfrac12\Big(h(|Z|)+\log\frac a\Delta\Big)+o(1),\qquad h(|Z|)=\tfrac12\log\frac{\pi e}2 . So the estimate grows without bound, like \tfrac12\log a.
- Many implementations instead bin ReLU activations into K equal bins on [0,\max T], the observed range. What happens to the estimate as a grows?
- In one sentence: what quantity is the binned estimator measuring?
Solution
1. The top bin is [1-2/K,1], and \Pr[T\ge1-2/K]=\Pr\big[Z\ge\operatorname{artanh}(1-2/K)/a\big]\to\Pr[Z>0]=\tfrac12 as a\to\infty. The bottom bin likewise tends to \tfrac12, so every other bin tends to 0. Entropy is continuous on the finite simplex, so H\to\log2: the unit has become a sign function, and the estimate counts two cells.
As a\to0, T\approx aZ concentrates at 0. With K even, 0 is a bin edge, so the two bins adjacent to 0 each get mass \to\tfrac12 and H\to\log2 again. With K odd, the middle bin straddles 0, takes all the mass, and H\to0.
2. For K=30, exact bin probabilities give (from checks/wb2b_check.py):
| a | 0.1 | 0.5 | 0.9 | 2 | 5 | 20 | 100 | 10^4 |
|---|---|---|---|---|---|---|---|---|
| H(\mathrm{bin}\tanh(aZ)) (nats) | 1.83 | 3.21 | 3.40 (max) | 2.88 | 1.92 | 1.10 | 0.80 | 0.69 |
At small a the activations occupy a few central bins. As a grows they spread over more bins, so the estimate rises (“fitting”). Past a\approx1 they pile up in the two saturated end bins, so it falls toward \log2 (“compression”). Monotone weight growth produces the two-phase curve with no change in what the network distinguishes: T stays an injective function of Z throughout.
3. Let S=\mathbf 1[Z>0]. All mass with Z\le0 sits at T=0, in bin 0, together with \Pr[0<Z<\Delta/a]\to0. Up to that vanishing overlap, S is a function of the bin, so H(\mathrm{bin}\,T)=H(S)+\Pr[S=1]\,H(\mathrm{bin}\,T\mid S=1)+o(1) =\log2+\tfrac12H\big(\mathrm{bin}_{\Delta/a}(|Z|)\big)+o(1). Given Z>0, Z has the density of |Z|, and binning aZ at width \Delta is binning Z at width \delta=\Delta/a\to0. So H(\mathrm{bin}_\delta|Z|)=h(|Z|)-\log\delta+o(1). The half-normal has h(|Z|)=\tfrac12\log(2\pi e)-\log2=\tfrac12\log(\pi e/2), which gives the formula. Check: with \Delta=1/15 and a=100 the formula gives 4.713 nats and the exact value is 4.710; at a=1000, 5.864 against 5.864. The ReLU estimate keeps growing, with no compression phase. This is the pattern Saxe et al. report.
4. \max(0,aZ)/\max_i(0,aZ_i) does not depend on a, so the binned estimate is exactly constant in a. The answer to 3 versus 4 is decided by a choice of bins, not by the network.
5. It measures how many cells of size \Delta the data occupy, i.e. the spread of the representation measured at a resolution fixed by the analyst. That is a geometric quantity. For a fixed binning rule it is a property of the distribution of T, but it is not generally equal to the unquantized I(X;T). The distribution and geometry of T can change even while the latter stays constant.