Quant Memo
Advanced

SGD Noise and Implicit Regularization

Stochastic gradient descent's mini-batch randomness isn't just a computational shortcut — it actively steers training away from the kind of overfit solutions full-batch gradient descent would happily settle into.

Prerequisites: Stochastic Gradient Descent, Loss Landscape Geometry and Sharpness

Explicit regularization is a deliberate penalty you add to the loss — an L2 term, dropout, early stopping — something you chose on purpose to fight overfitting. But networks trained with plain mini-batch stochastic gradient descent, no explicit penalty at all, still often generalise better than the same network trained with exact full-batch gradient descent on the identical data. Something about the procedure itself, not any penalty you bolted on, is doing regularising work. That something is the noise mini-batching introduces.

The analogy: a hiker who can't see the whole map

A full-batch optimiser is a hiker with a perfect map of the entire valley, walking the single steepest path down to whatever the lowest point happens to be — including a narrow, easily-missed crack if that's genuinely the deepest spot. A mini-batch optimiser is the same hiker in dense fog, only ever seeing the terrain immediately underfoot from a small sample of the ground. Each step is a decent local guess, but never a precise reading of the true steepest direction. That fog has a side effect: the hiker physically cannot thread the needle into a narrow crack, because doing so would require a precision the noisy readings don't have. The fog naturally steers the hiker toward wide, forgiving basins that are easy to stumble into and hard to stumble out of — exactly the flat regions that generalise well.

Where the noise comes from

Full-batch gradient descent computes the exact gradient over all NN training points. Mini-batch SGD estimates it from a random subset of size BB:

gbatch=1Ni=1Ni(θ),gSGD=1BiBi(θ)g_{\text{batch}} = \frac{1}{N}\sum_{i=1}^{N} \nabla \ell_i(\theta), \qquad g_{\text{SGD}} = \frac{1}{B}\sum_{i \in \mathcal{B}} \nabla \ell_i(\theta)

In words: the true gradient averages every training example's contribution; the SGD estimate averages only a random handful of them, and by how much it misses the true average shrinks as the batch gets bigger. The gap between the two, gSGDgbatchg_{\text{SGD}} - g_{\text{batch}}, behaves like injected noise with variance that scales roughly as 1/B1/B — small batches inject more noise, large batches inject less, and a full batch injects none. That noise doesn't cancel to zero at each step; it accumulates into a persistent random wobble around the descent path, and the wobble is large exactly where the loss surface curves sharply, which is precisely the signature of a narrow minimum. A ball rolling downhill with a persistent random jitter cannot settle at rest in a spot that punishes small deviations — it gets kicked back out.

Worked example 1: batch size versus effective noise, by hand

Take a toy loss surface where the gradient noise variance is σ2=4\sigma^2 = 4 per example. With batch size B=10B = 10, the variance of the batch gradient estimate is σ2/B=4/10=0.4\sigma^2 / B = 4/10 = 0.4, so its standard deviation (the typical wobble size) is 0.40.63\sqrt{0.4} \approx 0.63. With batch size B=1000B = 1000, variance is 4/1000=0.0044/1000 = 0.004, standard deviation 0.063\approx 0.063 — the wobble shrinks by roughly a factor of ten when the batch grows by a factor of one hundred, because noise scales with the square root of the batch size, not linearly. This is the direct mechanical reason large-batch training reaches sharper, more precisely-targeted minima: the optimiser simply has a much steadier hand.

Worked example 2: same architecture, two training runs

A network trained with batch size 32 and a network trained with batch size 8192 both reach training accuracy of 99.9% on the same dataset — full-batch-like precision on the training set either way. Post-training sharpness measurements (loss increase after a fixed weight perturbation, as in Loss Landscape Geometry and Sharpness) come out to 0.020.02 for the small-batch run and 0.450.45 for the large-batch run. On a held-out validation split, the small-batch model's accuracy drops to 97.5%, a gap of 2.4 points; the large-batch model's accuracy drops to 91.0%, a gap of 8.9 points — roughly three and a half times worse degradation, from a training run that looked identical on paper. Nothing about the loss function changed between the two runs; only the batch size, and therefore the noise level, did.

small batch: wobbles into flat basin large batch: dives into sharp crevice
Both trajectories reach a minimum of essentially the same loss; the noisy path cannot stay inside the narrow crevice and settles in the wide basin instead.

What this means in practice

This is why "just use the biggest batch your GPU memory allows" is not a free lunch — it removes a regularising force you were relying on without realising it. The common fixes acknowledge this directly: scale the learning rate up roughly in proportion to batch size to partially restore an equivalent noise level, add an explicit warm-up period, or reintroduce noise deliberately through other channels (dropout, data augmentation, label smoothing) to compensate for a large batch's precision. On financial datasets, where the temptation is often to use large batches purely for training-speed reasons on GPU clusters, this trade-off deserves explicit attention: a model that trains twice as fast but generalises measurably worse out-of-sample has not actually saved you anything.

The same logic explains why some practitioners deliberately keep batch sizes modest even when a larger batch would speed up wall-clock training time, treating the resulting noise as a regulariser worth its computational cost rather than a nuisance to be engineered away. It's also a useful diagnostic in reverse: if a model trained with a large batch and a carefully tuned learning rate still generalises noticeably worse than a small-batch baseline, sharpness of the resulting minimum, not an error in the learning-rate schedule, is a natural first suspect.

Gradient descent
parameter →
position -0.623loss -0.141gradient -0.930converging

Try a large step size in the explorer and watch the path overshoot and oscillate rather than gliding smoothly to the bottom — SGD's mini-batch noise produces a related, persistent version of that oscillation, which is what keeps it out of the sharpest, easily-overfit minima.

SGD's mini-batch noise is not merely tolerated inefficiency — it is an implicit regulariser that biases training toward flat, generalisable minima, doing for free part of the job explicit penalties like weight decay were designed to do on purpose.

The classic confusion: assuming a larger batch size is a strict computational upgrade because it produces a more accurate gradient estimate with the same total data seen. A more accurate gradient estimate is exactly the problem — it removes the noise that was steering the optimiser away from sharp, poorly-generalising minima. Larger batches usually need compensating changes (learning-rate scaling, added explicit regularization, or both) to match the generalisation of a smaller-batch run, not just a proportional increase in learning rate and nothing else.

Related concepts

Practice in interviews

Further reading

  • Keskar et al., On Large-Batch Training for Deep Learning: Generalization Gap and Sharp Minima
  • Smith & Le, A Bayesian Perspective on Generalization and Stochastic Gradient Descent
ShareTwitterLinkedIn