A Bayesian Perspective on Generalization and Stochastic Gradient Descent

Samuel L. Smith and Quoc V. Le, Unknown author

TL;DR

This paper argues that generalization in deep learning is driven by "Bayesian evidence"—a metric that penalizes complex, sharp minima while remaining immune to simple weight rescaling. By treating Stochastic Gradient Descent (SGD) as a physical system with a specific "noise scale," the authors derive a fundamental scaling rule: the optimal batch size is directly proportional to the learning rate and the training set size ($B_{opt} \propto \epsilon N$).

Introduction: The Generalization Paradox

Deep learning researchers have long been puzzled by a paradox: neural networks are powerful enough to "memorize" completely random labels, yet when given real data, they generalize beautifully. Why does the training process prefer solutions that work on new data over those that just memorize the old?

A popular theory was that SGD finds "flat minima," which generalize better than "sharp" ones. However, critics pointed out a major flaw: you can make a minimum look as sharp or flat as you want just by rescaling the model's weights without changing its predictions. This paper seeks a more robust mathematical explanation for generalization and aims to provide clear rules for how to tune hyperparameters like batch size and learning rate.

Methods

The authors bridge the gap between Bayesian statistics and practical optimization through two main lenses:

  1. Bayesian Model Comparison: They use "Bayesian evidence" (or marginal likelihood) to evaluate models. Unlike simple sharpness, the evidence includes an "Occam factor" that naturally penalizes narrow, complex regions of the parameter space but remains invariant to how you parameterize the model.
  2. Stochastic Differential Equations (SDE): The authors model the "noise" in SGD (caused by using mini-batches instead of the full dataset) as a continuous physical process. By doing this, they identify a "noise scale" ($g$) that governs how the model explores the landscape.
  3. Empirical Probing: They test these theories on MNIST using both simple logistic regression (to show these aren't just "deep" phenomena) and shallow neural networks, systematically varying batch sizes, learning rates, and training set sizes.

Datasets

The study primarily uses the MNIST dataset of handwritten digits.

  • To study memorization, they used a subset of 800 images with both informative (real) labels and randomized labels.
  • For the hyperparameter scaling experiments, they used a subset of 1,000 images to allow for high-precision comparisons between small-batch and full-batch training.

Key Insights and Ideas

  • Linear Models Memorize Too: The famous observation that deep nets can memorize random noise isn't unique to deep learning. Even a simple "over-parameterized" linear model (logistic regression) will perfectly memorize random labels if the regularization is weak enough.
  • The Evidence Ratio: The authors show that the Bayesian evidence ratio is a much more reliable predictor of generalization than cross-entropy or simple curvature. If the evidence for your model isn't higher than a "null model" (which just guesses randomly), it won't generalize.
Bayesian evidence strongly correlates with test performance, peaking where test cross-entropy is minimized.
  • The SGD Noise Scale: The most impactful idea is the derivation of the noise scale: $g \approx \epsilon N / B$. This suggests that the "shaking" of the optimizer—which helps it escape bad, sharp minima—is a delicate balance of the learning rate ($\epsilon$), the total number of examples ($N$), and the batch size ($B$).
  • Generalization has an Optimum: There isn't a "smaller is always better" rule for batch sizes. There is an optimal batch size that balances the need to find the bottom of a hole (depth) with the need to find a wide hole (breadth).

Key Results

  • Linear Scaling Rule: The authors empirically confirm that $B_{opt} \propto \epsilon$. If you double your learning rate, you should double your batch size to keep the optimization noise at the same "temperature."
  • Training Set Scaling: They also find $B_{opt} \propto N$. As you collect more data, you should increase your batch size to maintain optimal generalization.
  • Momentum Scaling: The paper extends the theory to momentum, showing that $B_{opt} \propto 1/(1-m)$. Increasing momentum is mathematically similar to increasing the learning rate; both require a larger batch size to stay in the "Goldilocks zone."
  • Practical Heuristic: The authors provide a concrete algorithm for researchers to find the largest possible batch size that doesn't sacrifice accuracy, enabling much faster parallel training.

Limitations and Future Work

  • Computational Complexity: Calculating the Hessian (the matrix of second derivatives) required for Bayesian evidence is computationally expensive for modern, massive neural networks with millions of parameters.
  • Gaussian Assumption: The SDE approach assumes that gradient noise follows a Gaussian distribution. While the authors show this holds for mini-batches of 30 on MNIST, it might break down in models with extremely sparse gradients or "heavy-tailed" noise.
  • Simple Architectures: While the principles are intended to be universal, the empirical tests were limited to relatively small models. Testing these scaling laws on massive Transformers or deep ResNets remains an area for broader validation.

Summary updated

BibTeX
@inproceedings{le2018bayesian,
  author = {Samuel L. Smith and Quoc V. Le and Unknown author},
  title = {{A Bayesian Perspective on Generalization and Stochastic Gradient Descent}},
  booktitle = {International Conference on Learning Representations},
  year = {2018},
  url = {https://openreview.net/forum?id=BJij4yg0Z},
}
Figure