Skip to main content
QUICK REVIEW

[Paper Review] A Bayesian Perspective on Generalization and Stochastic Gradient Descent

Samuel Smith, Quoc V. Le|arXiv (Cornell University)|Oct 17, 2017
Stochastic Gradient Optimization TechniquesComputer Science24 citations
TL;DR

This paper proposes that Bayesian evidence explains why stochastic gradient descent (SGD) generalizes well: it penalizes sharp minima while remaining invariant to model parameterization. The authors derive a noise scale $ g \approx \epsilon N / B $, showing an optimal batch size $ B_{\text{opt}} \propto \epsilon N $ that maximizes test accuracy, verified empirically across learning rates, batch sizes, and training set sizes.

ABSTRACT

We consider two questions at the heart of machine learning; how can we predict if a minimum will generalize to the test set, and why does stochastic gradient descent find minima that generalize well? Our work responds to Zhang et al. (2016), who showed deep neural networks can easily memorize randomly labeled training data, despite generalizing well on real labels of the same inputs. We show that the same phenomenon occurs in small linear models. These observations are explained by the Bayesian evidence, which penalizes sharp minima but is invariant to model parameterization. We also demonstrate that, when one holds the learning rate fixed, there is an optimum batch size which maximizes the test set accuracy. We propose that the noise introduced by small mini-batches drives the parameters towards minima whose evidence is large. Interpreting stochastic gradient descent as a stochastic differential equation, we identify the "noise scale" $g = ε(\frac{N}{B} - 1) \approx εN/B$, where $ε$ is the learning rate, $N$ the training set size and $B$ the batch size. Consequently the optimum batch size is proportional to both the learning rate and the size of the training set, $B_{opt} \propto εN$. We verify these predictions empirically.

Motivation & Objective

  • Explain why stochastic gradient descent (SGD) finds minima that generalize well, despite models memorizing random labels.
  • Address the paradox posed by Zhang et al. (2016), where deep networks memorize random labels yet generalize on real data.
  • Identify the role of mini-batch noise in driving SGD toward minima with high Bayesian evidence.
  • Derive and validate scaling rules for optimal batch size in relation to learning rate, training set size, and momentum.

Proposed method

  • Use Bayesian model comparison to evaluate model evidence, which penalizes sharp minima via an Occam factor independent of parameterization.
  • Model SGD as a stochastic differential equation with noise scale $ g \approx \epsilon N / B $, where $ \epsilon $ is learning rate, $ N $ training set size, and $ B $ batch size.
  • Derive the optimal batch size $ B_{\text{opt}} \propto \epsilon N $ by balancing noise-driven exploration and convergence to high-evidence minima.
  • Extend the analysis to SGD with momentum, deriving $ g \approx \frac{\epsilon N}{B(1 - m)} $ and $ B_{\text{opt}} \propto \frac{1}{1 - m} $, where $ m $ is the momentum coefficient.
  • Conduct empirical validation across varying learning rates, batch sizes, training set sizes, and momentum values to confirm scaling laws.
  • Use cross-entropy loss with L2 regularization and Gaussian priors to compute the cost function $ C(\omega; M) = H(\omega; M) + \lambda \omega^2 / 2 $, linking it to the posterior and evidence.

Experimental results

Research questions

  • RQ1Why do models trained with SGD generalize well on real labels even when they can memorize randomly labeled data?
  • RQ2How does mini-batch noise in SGD influence the selection of generalizing minima?
  • RQ3What is the relationship between optimal batch size, learning rate, and training set size in SGD?
  • RQ4How does momentum affect the optimal batch size in SGD?
  • RQ5Can Bayesian evidence explain generalization in both deep and small linear models?

Key findings

  • The phenomenon of memorizing random labels, observed in deep networks by Zhang et al. (2016), also occurs in small over-parameterized linear models.
  • Bayesian evidence explains generalization: it penalizes sharp minima and is invariant to model parameterization, resolving the memorization paradox.
  • An optimal batch size exists that maximizes test accuracy, and it scales linearly with both the learning rate and training set size: $ B_{\text{opt}} \propto \epsilon N $.
  • Empirical results confirm the linear scaling rule $ B_{\text{opt}} \propto \epsilon N $, with peak test accuracy stable up to $ \epsilon \sim 3 $, beyond which discretization error degrades performance.
  • For SGD with momentum, the optimal batch size scales as $ B_{\text{opt}} \propto \frac{1}{1 - m} $, and empirical results show strong agreement with this rule.
  • The optimal batch size increases with training set size, and the generalization gap diminishes as dataset size grows, supporting the use of larger batches in production settings with growing data.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.