On Large Batch Training and Sharp Minima: A Fokker–Planck Perspective

Xiaowu Dai, Yuhua Zhu

TL;DR

This paper provides a rigorous theoretical framework using the Fokker-Planck equation to explain why small-batch training typically finds "flatter" minima and generalizes better than large-batch training. The authors prove that while stochastic gradient descent (SGD) eventually gravitates toward flat minima regardless of batch size, the rate of this convergence is exponentially slower for large batches, effectively trapping them in "sharp" minima during practical training timescales.

What Problem Does This Paper Address?

In deep learning, there is a well-known empirical "generalization gap": models trained with large mini-batches often perform worse on test data than those trained with small batches. Previous research suggested this is because large batches converge to "sharp minima" (narrow valleys in the loss landscape), while small batches find "flat minima" (broad valleys), which are more robust to data shifts.

However, a formal mathematical explanation for why and how this happens has been elusive. This paper seeks to bridge that gap by analyzing the dynamic trajectory of SGD through the lens of continuous-time stochastic processes.

Methods

The authors employ a multi-step theoretical approach:

  1. SDE Approximation: They approximate discrete mini-batch SGD and Momentum SGD (MSGD) as continuous Stochastic Differential Equations (SDEs). This allows them to treat the "noise" introduced by mini-batches as a diffusion process.
  2. Fokker-Planck Equations: They use the Fokker-Planck equation (and the Vlasov-Fokker-Planck variant for momentum) to describe how the probability distribution of the model parameters evolves over time.
  3. Eyring-Kramers Formula: To study the "escaping phenomenon," they use this formula from chemical physics to calculate the expected time it takes for the optimizer to jump out of a local minimum.
  4. Hypocoercivity: For Momentum SGD, which results in a "degenerate" diffusion (noise only enters through velocity, not position), they use the mathematical theory of hypocoercivity to prove convergence rates to the stationary distribution.

Datasets

The theoretical findings are validated using standard benchmarks:

  • MNIST: Trained on a 4-layer multilayer perceptron (MLP) with ReLU and batch normalization.
  • CIFAR-10: Trained on two architectures:
  • N1: A shallow convolutional network (modified AlexNet).
  • N2: A deep convolutional network (modified VGG).

Key Insights and Ideas

  • Sharpness Defined: The authors define "sharpness" mathematically as the determinant of the Hessian of the loss function ($|\nabla^2 L|$). A larger determinant signifies a sharper, steeper minimum.
  • The Escaping Mechanism: Small batches increase the variance (noise) of the gradient estimate. This noise acts like "thermal energy," allowing the optimizer to escape narrow, sharp minima quickly. Large batches have lower variance, leaving them "trapped" in the first sharp valley they encounter.
  • The Asymptotic Surprise: Theoretically, in the limit of infinite time ($t \to \infty$), the optimizer will always prefer flatter minima regardless of batch size.
  • The Convergence Trade-off: The "aha moment" is that the convergence rate to these ideal flat regions depends heavily on the batch size ($M$). Specifically, the rate is proportional to $1/M$. Therefore, while a large batch could eventually find a flat minimum, it might take orders of magnitude more iterations than are practical in a real-world training run.

Key Results

  • Escaping Time: Lemma 2 shows that the time to escape a minimum grows exponentially with the batch size $M$.
  • Probability Ratio: Theorem 2 proves that the probability of the optimizer being in a specific minimum is inversely proportional to the square root of the determinant of the Hessian at that point. This confirms that "flat" regions (low determinant) are statistically much more likely to be occupied in the long run.
  • Empirical Confirmation: Experiments showed that small batches (e.g., $M=64$) reached significantly flatter regions (measured by the Frobenius norm of the Hessian) much faster than large batches (e.g., $M=512$). For instance, on CIFAR-10 with a deep ConvNet, small batches reached a "flatness" threshold in 4,000 steps that large batches hadn't reached even after 10,000 steps.

Limitations and Future Work

  • Isotropic Noise: The authors assume the gradient noise is isotropic (equal in all directions) to keep the math tractable. In reality, gradient noise in deep networks is highly anisotropic (directional), which likely plays a further role in navigation.
  • SDE Approximation Limits: The approximation of discrete SGD by continuous SDEs is most accurate when the learning rate is very small. The authors acknowledge that a "uniform-in-time" approximation for non-convex losses is still an open mathematical challenge.
  • Anisotropic Extensions: The authors suggest that extending this framework to account for the true anisotropic structure of gradient covariance is a primary direction for future research.

Summary updated

BibTeX
@article{dai2020large,
  author = {Xiaowu Dai and Yuhua Zhu},
  title = {{On Large Batch Training and Sharp Minima: A Fokker–Planck Perspective}},
  journal = {Journal of Statistical Theory and Practice},
  year = {2020},
  url = {https://openreview.net/forum?id=hOfvsd0g1f},
}
Figure