Before you move a control in the demo, say what you expect to change.
Foundation reference
Batch Normalization
Batch normalization subtracts each feature's mean and divides by its standard deviation, both computed over the current mini-batch during training, then applies a learned scale and shift. It made deep convolutional networks much faster to train: an Inception image classifier reached the same accuracy in 14 times fewer training steps (Ioffe & Szegedy, 2015), and ResNets apply it after every convolution (He et al., 2016).
Study guide
Where to start
Ioffe & Szegedy motivated batch normalization as a cure for "internal covariate shift"; why did Santurkar et al. (2018) conclude that it helps mainly by making the loss and its gradients smoother instead?
How to study this pagePredict · Check · Generalize · Continue
Compare what the demo shows with the key equation and with the papers cited below.
Identify the part of the idea that survives a change of notation or model, so you can recognize it in another paper or system.
Use the prerequisites and related concepts at the end of the page to fill the next gap.
Why It Matters for Modern Models
- Batch normalization subtracts each feature's mean and divides by its standard deviation, both computed over the current mini-batch during training, then applies a learned scale and shift. It made deep convolutional networks much faster to train: an Inception image classifier reached the same accuracy in 14 times fewer training steps (Ioffe & Szegedy, 2015), and ResNets apply it after every convolution (He et al., 2016).
- It allows much higher learning rates and makes training less sensitive to initialization (Ioffe & Szegedy, 2015).
- The switch from batch statistics during training to running averages at test time is a common source of bugs, for example when a model is evaluated in training mode or when the test data differ from the training data.
Questions to Think About
- Because each example is normalized with its batch-mates' statistics, its output and gradient depend on which other examples share the batch; what problems can that cause?
- Why does the error of batch-normalized networks rise quickly as the batch gets small (Wu & He, 2018), and why do transformers use layer normalization, which needs no batch statistics, instead?
Interactive Demo
Core Math
If you prefer intuition first, try the demo above, then come back for the math.
Batch normalization normalizes each feature with the mean and variance over the examples in the current mini-batch. For a convolutional channel, the statistics also include all spatial positions, so below counts batch elements times spatial positions:
where and .
Learned parameters then scale and shift the result, so the layer can still produce whatever mean and variance the next layer needs:
At inference there may be no batch, so the layer uses running averages of and collected during training. The network therefore computes a slightly different function at training and test time.