Generalization Theory & PAC-Bayes

Why do overparameterized networks generalize? Formal treatment of VC dimension, Rademacher complexity, PAC-Bayes bounds, the role of flatness/sharpness of minima, and the lottery ticket hypothesis.

Advanced

Table of Contents

  1. Learning Objectives
  2. Notation
  3. Core Intuition
  4. Classical Generalization Bounds
  5. VC Dimension of Neural Networks
  6. Rademacher Complexity
  7. PAC-Bayes Bounds
  8. Flat vs Sharp Minima
  9. Implicit Regularization of SGD
  10. Double Descent Revisited
  11. Common Pitfalls
  12. Research Perspective
  13. Summary
  14. Exercises

Learning Objectives

  1. State the classical uniform convergence bound and identify why it fails for deep networks.
  2. Define VC dimension and Rademacher complexity.
  3. State the PAC-Bayes theorem and interpret the KL divergence penalty.
  4. Explain the flat minima hypothesis and its connection to generalization.
  5. Describe how SGD implicitly regularizes toward low-complexity solutions.

Notation

  • R(f)R(f) — population risk, R^n(f)\hat{R}_n(f) — empirical risk
  • F\mathcal{F} — hypothesis class
  • VC(F)\text{VC}(\mathcal{F}) — VC dimension
  • Rn(F)\mathcal{R}_n(\mathcal{F}) — Rademacher complexity
  • QQ — posterior distribution over hypotheses
  • PP — prior distribution over hypotheses
  • KL(QP)\text{KL}(Q \| P) — KL divergence from prior to posterior

Core Intuition

Classical statistical learning theory says: more parameters = higher complexity = more overfitting. Yet modern neural networks with millions of parameters generalize well despite perfectly fitting (interpolating) training data. This "mystery of generalization" in deep learning requires going beyond traditional bounds and understanding the implicit biases of the optimization algorithm, architecture, and parameterization.

Generalization Gap

EpochsLoss
Gap = 1.575Best @ epoch 49
Epoch
40
Complexity
3
TrainTest (U-shape)Gap
Explore: Training loss always decreases, but test loss rises after the optimum (overfitting). Stop at the green dashed line — early stopping minimizes the generalization gap.

Classical Generalization Bounds

Uniform convergence: With probability 1δ\geq 1-\delta, for all fFf \in \mathcal{F}:

R(f)R^n(f)+complexity(F)+log(1/δ)n.(1)R(f) \leq \hat{R}_n(f) + \sqrt{\frac{\text{complexity}(\mathcal{F}) + \log(1/\delta)}{n}}. \tag{1}

The "complexity" term depends on the measure: VC dimension, covering numbers, or Rademacher complexity.


VC Dimension of Neural Networks

Definition. The VC dimension of F\mathcal{F} is the largest set of points that can be shattered (classified in all 2n2^n possible ways) by functions in F\mathcal{F}.

For neural networks: A network with WW weights has VC dimension Θ(WlogW)\Theta(W\log W) (Bartlett et al., 1998). For a modern network with W=109W = 10^9 parameters and n=106n = 10^6 samples, the bound gives:

gap10930106170.(2)\text{gap} \sim \sqrt{\frac{10^9 \cdot 30}{10^6}} \sim 170. \tag{2}

This is vacuous (greater than the maximum possible loss). Classical bounds completely fail to explain neural network generalization.


Rademacher Complexity

Definition. The empirical Rademacher complexity of F\mathcal{F}:

R^n(F)=Eσ[supfF1ni=1nσif(xi)],(3)\hat{\mathcal{R}}_n(\mathcal{F}) = \mathbb{E}_{\boldsymbol\sigma}\left[\sup_{f \in \mathcal{F}}\frac{1}{n}\sum_{i=1}^n \sigma_i f(x_i)\right], \tag{3}

where σi{1,+1}\sigma_i \in \{-1, +1\} are independent Rademacher random variables.

Interpretation: How well can F\mathcal{F} correlate with random noise? High correlation = high complexity.

Bound: R(f)R^n(f)+2Rn(F)+log(1/δ)2nR(f) \leq \hat{R}_n(f) + 2\mathcal{R}_n(\mathcal{F}) + \sqrt{\frac{\log(1/\delta)}{2n}}.

For neural networks with bounded weights (spectral norm constraints), norm-based Rademacher bounds can be non-vacuous.


PAC-Bayes Bounds

The PAC-Bayes framework bounds the expected risk of a distribution QQ over hypotheses:

Theorem (McAllester, 1999). For any prior PP (chosen before seeing data) and any δ>0\delta > 0, with probability 1δ\geq 1-\delta over the draw of training data, for all posteriors QQ:

EfQ[R(f)]EfQ[R^n(f)]+KL(QP)+log(n/δ)2(n1).(4)\mathbb{E}_{f \sim Q}[R(f)] \leq \mathbb{E}_{f \sim Q}[\hat{R}_n(f)] + \sqrt{\frac{\text{KL}(Q \| P) + \log(n/\delta)}{2(n-1)}}. \tag{4}

Interpretation: The generalization gap is bounded by how much the learned distribution QQ diverges from the prior PP. If training doesn't move far from initialization (small KL), generalization is guaranteed.

Application to neural networks: Let P=N(θ0,σP2I)P = \mathcal{N}(\boldsymbol\theta_0, \sigma_P^2\mathbf{I}) (centered at initialization) and Q=N(θ^,σQ2I)Q = \mathcal{N}(\hat{\boldsymbol\theta}, \sigma_Q^2\mathbf{I}) (centered at learned weights). Then:

KL(QP)=dσQ2+θ^θ022σP2d2+d2logσP2σQ2.(5)\text{KL}(Q \| P) = \frac{d\sigma_Q^2 + \lVert\hat{\boldsymbol\theta} - \boldsymbol\theta_0\rVert^2}{2\sigma_P^2} - \frac{d}{2} + \frac{d}{2}\log\frac{\sigma_P^2}{\sigma_Q^2}. \tag{5}

The bound is tighter when parameters stay close to initialization and when the posterior is concentrated (low σQ\sigma_Q).


Flat vs Sharp Minima

Hypothesis: Networks that converge to "flat" minima (large region with low loss) generalize better than those at "sharp" minima.

Formalization (Keskar et al., 2017): Sharpness of minimum θ\boldsymbol\theta^*:

sharpness=maxϵρR^(θ+ϵ)R^(θ).(6)\text{sharpness} = \max_{\lVert\boldsymbol\epsilon\rVert \leq \rho} \hat{R}(\boldsymbol\theta^* + \boldsymbol\epsilon) - \hat{R}(\boldsymbol\theta^*). \tag{6}

Flat minima are robust to perturbations → robust to train/test distribution shift.

Connection to PAC-Bayes: A flat minimum allows a wide Gaussian posterior QQ around θ^\hat{\boldsymbol\theta} with low expected empirical risk, reducing the KL term and yielding a tighter bound.

SAM (Sharpness-Aware Minimization): Explicitly minimizes the worst-case loss in a neighborhood, seeking flat minima:

minθmaxϵρR^(θ+ϵ).(7)\min_{\boldsymbol\theta}\max_{\lVert\boldsymbol\epsilon\rVert \leq \rho}\hat{R}(\boldsymbol\theta + \boldsymbol\epsilon). \tag{7}

Implicit Regularization of SGD

SGD with finite learning rate introduces implicit biases:

  1. Minimum-norm bias: Gradient flow from zero initialization converges to the minimum-norm interpolant (see Gradient Flow).
  2. Noise-induced regularization: SGD noise (from mini-batches) helps escape sharp minima, favoring flat ones.
  3. Edge of stability: With large learning rate, SGD oscillates at the edge of stability, implicitly regularizing the largest Hessian eigenvalue.
  4. Label noise robustness: Early in training, SGD learns signal (low-frequency patterns) before noise (high-frequency) — "early stopping" regularizes even without explicit stopping.

Double Descent Revisited

The test error as a function of model complexity (dd):

test error(d)={bias-dominated (underfitting)dnpeak at interpolation thresholddndecreasing (benign overfitting)dn(8)\text{test error}(d) = \begin{cases} \text{bias-dominated (underfitting)} & d \ll n \\ \text{peak at interpolation threshold} & d \approx n \\ \text{decreasing (benign overfitting)} & d \gg n \end{cases} \tag{8}

In the heavily overparameterized regime, many interpolating solutions exist; SGD selects the one with favorable properties (minimum norm, flat, aligned with data structure).


Common Pitfalls

Pitfall 1. Citing VC dimension bounds for neural networks as meaningful. They are astronomically loose — orders of magnitude above any achievable gap.

Pitfall 2. Equating "interpolation" with "overfitting." In the overparameterized regime, interpolating models can generalize perfectly well due to implicit regularization.

Pitfall 3. Assuming flatness alone explains generalization. Flatness is parameterization-dependent (reparameterizing weights can make any minimum appear flat or sharp).


Research Perspective

Understanding why deep networks generalize remains one of the central open problems in machine learning theory. Current leading explanations involve: (1) implicit bias of SGD toward low-complexity solutions, (2) the structure of real data (low intrinsic dimension), (3) architecture-induced biases (convolutions, attention), and (4) the neural tangent kernel regime for very wide networks. No single theory fully explains all observations.


Summary

  • Classical VC/Rademacher bounds are vacuous for modern networks.
  • PAC-Bayes provides tighter bounds via the KL between learned and prior distributions.
  • Flat minima generalize better; SGD is biased toward finding them.
  • Implicit regularization of SGD (minimum norm, noise-induced) partially explains generalization.
  • Double descent shows that more parameters can improve generalization beyond the interpolation threshold.

Exercises

Exercise 1. Compute the VC dimension of the class of linear classifiers in Rd\mathbb{R}^d and verify it equals d+1d+1.

Exercise 2. For a prior P=N(0,σ2I)P = \mathcal{N}(0, \sigma^2\mathbf{I}) and posterior Q=N(μ,σ2I)Q = \mathcal{N}(\boldsymbol\mu, \sigma^2\mathbf{I}), compute KL(QP)\text{KL}(Q \| P).

Exercise 3. Show that adding Gaussian noise to weights is equivalent to L2 regularization in expectation (for quadratic loss).

Exercise 4. For a linear model interpolating nn points in d>nd > n dimensions, derive the minimum-norm solution and show it generalizes better than a random interpolant.

Exercise 5. Explain why the "edge of stability" phenomenon (loss oscillating but not diverging with large learning rate) constitutes implicit regularization of the Hessian's top eigenvalue.