ML Systems Lab Open interactive version →
Intermediate 31 min read batch normlayer normregularisation

Batch Normalisation & Regularisation

BatchNorm vs LayerNorm — why normalisation stabilises training, and why it comes with free regularisation

Choosing the right activation fixed how gradients flow *through* each layer — but it says nothing about what a layer's *inputs* look like from one training step to the next. Take a 10-layer network mid-training. Layer 5 tweaks its weights — fine. But layer 6 had learned to expect a certain *distribution* of numbers coming from layer 5, and that distribution just moved. So layer 6 scrambles to adjust, which shifts what layer 7 sees, and so on up the stack. Every layer is chasing a moving target created by the layers below it. To keep this from blowing up, you are forced to use a tiny learning rate so no single update destabilises everything above it — and training crawls. This wobble was one of the big reasons deep networks were so fragile to train before 2015.

Batch normalisation fixed it with a simple idea: at each layer, before passing the numbers on, *re-centre and re-scale them* so they have a consistent, tidy distribution (mean 0, spread 1 — using the batch's own mean μ_batch and spread σ_batch) across the batch. Now layer 6 always sees inputs in a familiar range no matter what layer 5 did, and the moving-target problem largely goes away. (It also keeps a pair of learned dials, γ and β, that let the network re-stretch the numbers if the task actually needs it, so nothing is lost.) The payoff is big: the original paper (Ioffe & Szegedy, 2015) reports raising the learning rate by roughly 5× in their main experiment — and up to 30× in a more aggressive variant — above what worked without it, the network stops caring so much about initialisation, and training converges much faster. (Later work — Santurkar et al., 2018 — argued this speed-and-stability payoff comes less from taming the moving-target problem and more from smoothing the loss landscape, making the optimisation surface easier to descend regardless of which story you tell about the mechanism.)


A happy side effect: free regularisation

Here is a subtlety that turns out to matter. The mean and spread used to normalise are computed from the *current mini-batch* — so the exact same example gets normalised a little differently depending on which other examples happen to share its batch. That tiny, ever-changing jitter acts like a mild regulariser: the network cannot lean too hard on any one example's exact representation, because that representation keeps shifting.


Batch norm vs layer norm — not interchangeable

There is a second normaliser, layer norm, and picking the wrong one is a genuine error, not a tuning choice. Batch norm normalises each feature *across the batch* — which only makes sense if the examples in a batch are comparable. In a Transformer chewing through tokens from different positions in different sentences, "the average of this feature across the batch" is semantic nonsense. Layer norm instead normalises *across the features of a single example*, so it is well-defined for one token at a time, at any position, with any batch size. That is why every Transformer uses layer norm, and CNNs on images use batch norm.

(One practical gotcha with batch norm: at inference you have no batch, so it switches to running averages collected during training. Forget to flip the model into eval mode and a single-example prediction gets normalised against a batch of one — which quietly produces garbage, with no error.)

Key points

Takeaway

Normalisation stabilises the optimisation landscape so training converges; regularisation reduces capacity so the solution generalises — conflating the two is the source of most tuning mistakes.

Recap

Check your understanding

Q1. Batch normalisation has four parameters per feature: γ, β, μ_batch, σ_batch. Which are learned and which are computed? What happens at inference time?

Q2. Why does batch normalisation act as a regulariser, reducing the need for dropout? Select the TWO correct mechanisms.

Q3. Layer normalization vs batch normalization: when do you use each, and what is the key structural difference?

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →