WHY FLATNESS DOES AND DOES NOT CORRELATE WITH GENERALIZATION FOR DEEP NEURAL NETWORKS

Shuofeng Zhang, Isaac Reid, Guillermo Valle-Perez, Ard A. Louis

TL;DR

While deep learning folklore suggests that "flatter" loss minima generalize better, standard flatness metrics can easily be fooled by parameter re-scaling or broken by switching optimizers from SGD to Adam. This paper shows that the Bayesian prior over functions at initialization, $\log P(f)$—representing the volume of parameter space that maps to a given function—provides a much more robust and scale-invariant predictor of generalization across different optimizers, overtraining regimes, and architectures.

What Problem Does This Paper Address?

A central puzzle in deep learning theory is why heavily overparameterized networks generalize well instead of overfitting noise. The most popular intuition is that stochastic gradient descent (SGD) biases training toward flat minima in the loss landscape, and that flatter minima naturally generalize better.

However, this narrative has cracks:

  1. Prior work showed that local flatness metrics (such as Hessian eigenvalues or loss sensitivity) can be arbitrarily manipulated through simple weight rescaling (e.g., in ReLU networks) without altering the network's actual input-output function.
  2. Even without malicious rescaling, it is unclear whether popular optimizers consistently find minima whose flatness correlates with performance.

The authors explore why local flatness metrics frequently fail to predict generalization and ask what fundamental property of the loss landscape actually drives generalization.

Methods

To separate algorithmic quirks from fundamental properties of the model, the authors contrast local flatness with a function-space perspective:

  • Evaluating Flatness: The authors examine several common flatness metrics, including Keskar's "sharpness" (measuring worst-case loss within a small parameter perturbation box, solved via SGD), the spectral norm of the Hessian, and the product of the top 50 Hessian eigenvalues.
  • Measuring Function Volume / Bayesian Prior, $P(f)$: For discrete classification, a network maps parameters $w$ to a discrete function $f$ over the dataset. The prior $P(f)$ is the probability that randomly initialized weights produce function $f$—equivalent to the volume of parameter space mapped to $f$.
  • For small models, $P(f)$ is estimated via direct Monte Carlo sampling ($10^8$ samples).
  • For deep networks on real datasets, the authors approximate $P(f)$ using Neural Network Gaussian Processes (NNGPs) in the infinite-width limit combined with Expectation Propagation (EP).
  • Varying Generalization via Attack Sets: To produce a wide spectrum of zero-training-error solutions with varying test accuracy, the authors use an "attack set" (Wu et al., 2017) of incorrectly labeled data mixed into the training set.

Datasets

The authors evaluate models on three benchmark setups:

  • $n=7$ Boolean Functions: A toy system with all $2^7 = 128$ binary inputs, small enough to directly sample the true function prior across $10^8$ random initializations.
  • Binarized MNIST: Handwritten digits grouped into two classes (digits 0–4 vs. 5–9), evaluated with $|S| = 500$ and $|S| = 10{,}000$ training examples.
  • Binarized CIFAR-10: Binary image classification between "cars" and "cats" ($|S| = 5000$).

Key Insights and Ideas

  • Optimizers Break the Flatness Correlation: While vanilla SGD and full-batch GD show a modest correlation between flatness and generalization, popular adaptive and entropy-based optimizers (Adam, Entropy-SGD, RMSProp, Adagrad) completely break this relationship. Under Adam, models with identical test performance can have drastically different sharpness values.
  • Flatness Drifts During Overtraining: Once a network achieves 100% training accuracy, continuing to train decreases cross-entropy loss and steadily increases "flatness," even though the actual discrete classification function and generalization error remain identical.
  • $\log P(f)$ is Invariant and Universal: Unlike local derivatives, the Bayesian prior $\log P(f)$ is a global property of the parameter-function map. It is completely invariant to parameter rescaling and maintains an extraordinarily tight linear correlation with generalization across vanilla SGD, Adam, Entropy-SGD, and others.
  • Flatness as a Flawed Proxy for Volume: Flatter minima often correlate with generalization in simple SGD settings because they correlate on average with large parameter-space volume $P(f)$ ("arrival of the frequent"). However, local curvature varies widely across the same basin of attraction, making local flatness a noisy, fragile proxy for basin volume.

Key Results

  • Boolean Model ($n=7$): The 1,000 most frequent functions found by SGD show that $\log(\text{flatness})$ correlates directly with $\log P(f)$, confirming that flatter regions generally correspond to higher-volume functions.
  • MNIST & CIFAR-10 Experiments: On fully connected networks (FCNs) and ResNet-50, $\log P(f)$ tightly tracks test accuracy as attack-set corruption varies generalization from ~50% to ~90%. In contrast, sharpness plots for Adam and Entropy-SGD are widely scattered and show virtually no predictive correlation.
  • Parameter Rescaling & Recovery: Applying $\alpha$-scaling ($\alpha = 5.9$) causes an instant, massive spike in sharpness. When training resumes, SGD initially gets bumped out of the low-loss manifold, but quickly relaxes back toward the same high-volume function, returning sharpness to its baseline level.

Limitations and Future Work

  • Computational Cost of $P(f)$: Evaluating $P(f)$ via NNGP and Expectation Propagation scales poorly with sample size, limiting experiments to smaller datasets or binary subsets (e.g., $|S| \le 10{,}000$).
  • Heuristic PAC-Bayes Bounds: While non-uniform PAC-Bayes bounds theoretically motivate the $-\log P(f)$ scaling, a fully rigorous, tight generalization bound directly bridging individual function priors and data distributions remains open.
  • Task Scope: The paper focuses primarily on binary classification with discrete input-output mappings. Extending these empirical insights to multi-class classification and continuous regression tasks remains an important direction.

Summary updated

BibTeX
@inproceedings{zhang2022why,
  author = {Shuofeng Zhang and Isaac Reid and Guillermo Valle-Perez and Ard A. Louis},
  title = {{WHY FLATNESS DOES AND DOES NOT CORRELATE WITH GENERALIZATION FOR DEEP NEURAL NETWORKS}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=L1L2G43k14n},
}

Loading related content...

Figure