Paper commentary
On Large-Batch Training for Deep Learning: Generalization Gap and Sharp Minima
Large-batch training generalizes worse because it finds sharp minima
- Problem Large-batch training speeds up deep learning across many machines, but test accuracy drops compared with small batches. Early stopping does not fix it, because the drop is not classic overfitting.
- Method The authors measure sharpness as the largest loss rise inside a small box around a solution. They compare minima found by small-batch and large-batch training on six networks.
- Results Large-batch minima are far sharper, with sharpness values differing by 1 to 2 orders of magnitude from small-batch minima. The authors do not prove the link between sharp minima and poor generalization.
Where large-batch training loses test accuracy
Deep networks are usually trained with stochastic gradient descent or one of its variants, which step along gradients estimated from a mini-batch. Larger batches would let each iteration spread over more machines, but practitioners see test accuracy fall when the batch grows. The authors call this drop the generalization gap, and in their experiments it reaches 5% even for smaller networks.
A large-batch method that kept its test accuracy could therefore scale to far more nodes, which is why the gap matters.
The comparison covers six networks, F1, F2, C1, C2, C3 and C4, pairing fully connected models with MNIST and TIMIT and convolutional models with CIFAR-10 and CIFAR-100. Both regimes use ADAM, with 256 data points per small batch and 10% of the training data per large batch. Every setting was run five times from different random starting points.
Training accuracy is high in both regimes, so the large-batch runs still fit the training data. Test accuracy is the part that separates them: for F2 it is 64.02% ± 0.2% with small batches, compared to 59.45% ± 1.05% with large batches. For C1 the figures are 80.04% ± 0.12% for small batches, compared to 77.26% ± 0.42% for large batches.
The drop is not classic overfitting, because test accuracy in these runs does not peak and then decay as training goes on. So early stopping, which targets overfitting, would not close the gap.
Sharp minima as the suspected cause
The authors list four candidate causes, including overfitting, attraction to saddle points, and weaker exploration, and their data favors the last two. Their central idea is that large-batch runs converge to sharp minimizers, while small-batch runs settle in flat minimizers. A sharp minimizer has many large positive eigenvalues of the Hessian, whereas a flat minimizer has many small eigenvalues.
A flat minimum can be specified at low precision, while a sharp minimum needs high precision. The authors connect this to the minimum description length view, in which models that need fewer bits to describe generalize better. That motivation comes from prior work, and this study does not prove it.
The authors suggest that gradient noise explains why the two regimes end in different minima. Small-batch noise can push iterates out of the basin of a sharp minimizer, while large-batch noise above the threshold is too weak to do so.
Measuring sharpness with a box
Computing the eigenvalues of the Hessian is too expensive for deep networks, so the authors use a sensitivity measure instead. The measure takes the largest value of the loss inside a box around the solution, which shows how fast the loss can rise nearby.
The box C_ε is built from a random matrix A with p = 100 columns for the random-subspace variant, and ε sets its size. For the full space the matrix A is the identity, so the box lives in all of the weight space. The metric is given by the formula below, where the maximum runs over y in the box.
\[ \varphi_{x,f}(\epsilon,A)=\frac{\max_{y\in C_\epsilon} f(x+Ay)-f(x)}{1+f(x)}\times 100 \] The numerator is the largest rise of f above f(x) inside the box, the denominator is 1 + f(x), and the ratio is scaled by 100.
The authors use ε = 10−3 and ε = 5·10−4, and they solve the maximization inexactly with 10 iterations of L-BFGS-B. The cap on iterations is needed because each evaluation of the true objective is expensive.
Sharpness of large-batch and small-batch minima
In the full space at ε = 10−3, F2 has sharpness 1.39 ± 0.02 with small batches, compared to 310.64 ± 38.46 with large batches. Across the networks the authors report a difference of 1 to 2 orders of magnitude between the SB and LB values. The authors read this as large-batch solutions being points of much larger sensitivity of the training function.
In random 100-dimensional subspaces the ordering holds too, with F2 at 0.29 ± 0.02 for small batches and 23.63 ± 0.54 for large batches at ε = 10−3. Large-batch minima are sharper than small-batch minima for all six networks in these subspaces.
The sharp minima do not look like a cone, since the loss rises steeply only along a small subspace, for example about 5% of the whole space. Along most other directions the function stays relatively flat. The authors note that the sharpness metric is closely related to the spectrum of the Hessian.
Walking between a small-batch and a large-batch minimizer
The authors take one SB and one LB minimizer from one of the five trials and evaluate the loss along a segment between them. The segment is parameterized as \( f(\alpha x^\star_{\ell}+(1-\alpha)x^\star_s) \) with α in [−1, 2], where α = 0 is the SB minimizer and α = 1 is the LB minimizer. Accuracy at the intermediate points is plotted on the same axes as the loss.
The large-batch minimum is much sharper than the small-batch minimum in this one-dimensional slice. The authors also plot a curved path in Figure 7 of Appendix D, where the sharpness difference is again visible. A single line only samples one direction, so it shows the contrast along that line and nothing more.
Warm-starting large-batch runs from small-batch iterates
The authors first train with ADAM at batch size 256 for 100 epochs and keep the iterate from each epoch. Each saved iterate then starts a large-batch run for 100 epochs, which gives 100 warm-started large-batch solutions. The test accuracy and sharpness of these runs depend on how many small-batch epochs came before them.
Starts after only a few small-batch epochs give no generalization gain, and their sharpness stays high. Later starts improve test accuracy and lower sharpness. The authors read this as the small-batch phase having found a flat minimizer that the large-batch run can then reach.
Along the loss trajectory, the two regimes have similar sharpness near the starting point. As the loss falls, the large-batch sharpness rises rapidly, while the small-batch sharpness stays roughly constant and then falls. The distance from the start for the small-batch solution was 3 to 10 times the distance for the large-batch solution.
Where a larger batch starts to hurt
Sweeping the batch size shows a threshold near 15000 for F2 and near 500 for C1, after which testing accuracy drops. Around that threshold the upward drift in sharpness is reduced.
The authors explain the threshold with the noise argument: above it, the gradient noise is too small to eject the iterates from the initial basin. So the threshold marks where the small-batch mechanism stops working.
Attempts to close the gap
The authors tried data augmentation, conservative training and adversarial training on the large-batch setting. Data augmentation enlarges the training set with controlled changes to its examples, and adversarial training uses the model's sensitivity to build new examples.
In preliminary tests these approaches reduce the generalization gap. But the resulting minima remain relatively sharp, so they don't fully remedy the problem.
Dynamic sampling, which raises the batch size gradually, is another suggested remedy, and the warm-starting results are cited as support.
Limits and open questions
The link between large-batch training and sharp minima rests on numerical evidence, and the authors don't prove that large-batch methods converge to sharp minimizers. The authors list this proof as an open question.
Sharpness is estimated with only 10 L-BFGS-B iterations, which is a coarse approximation of the maximization. The experiments cover six networks on four data sets, with five runs per setting.
The authors raise further open questions, including the relative density of sharp and flat minima and whether network design or initialization can suit large-batch training. The theoretical work on loss surfaces shows many minimizers with similar loss values, but it's unknown whether it describes sharp minimizers.
Paper info
- Authors
- Nitish Shirish Keskar, Dheevatsa Mudigere, Jorge Nocedal, Mikhail Smelyanskiy, Ping Tak Peter Tang
- Venue
- arXiv · Preprint
- First published
- 2016-9-15
- Added
- 2026-11-12
- Updated
- 2017-2-9
- Version
- v2
- arXiv
- 1609.04836
- Category
- cs.LG · math.OC
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Nitish Shirish Keskar, Dheevatsa Mudigere, Jorge Nocedal, Mikhail Smelyanskiy, Ping Tak Peter Tang (2016). On Large-Batch Training for Deep Learning: Generalization Gap and Sharp Minima. arXiv:1609.04836v2. https://arxiv.org/abs/1609.04836v2
BibTeX
@misc{keskar2016large,
title = {{On Large-Batch Training for Deep Learning: Generalization Gap and Sharp Minima}},
author = {Nitish Shirish Keskar and Dheevatsa Mudigere and Jorge Nocedal and Mikhail Smelyanskiy and Ping Tak Peter Tang},
year = {2016},
eprint = {1609.04836},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1609.04836v2}
}