What is batch normalization?
Batch normalization (BN) is a layer that normalizes each feature to zero mean and unit variance using statistics from the current mini-batch, then applies a learned scale γ and shift β. It is usually placed between a linear or convolutional layer and its activation. At inference time it uses running averages of the mean and variance collected during training.
Ioffe and Szegedy introduced batch normalization in 2015, and it quickly became standard in convolutional networks such as ResNet. It allows higher learning rates, makes training less sensitive to initialization, and adds a mild regularizing effect. Transformers mostly use layer normalization instead, which normalizes across the values within each example and does not depend on the batch.
Key ideas
- Batch normalization rescales each feature to zero mean and unit variance within a mini-batch.
- Learned parameters γ and β let the network restore any scale and shift it needs.
- Training uses batch statistics; inference uses running averages collected during training.
- BN permits higher learning rates and reduces sensitivity to weight initialization.
- Small batches make BN's statistics noisy, which is why transformers use layer normalization.
- Why BN works is still debated; smoothing the loss surface is a leading explanation.
Short takes on this topic
Common questions
What is the difference between batch normalization and layer normalization?
Batch normalization computes the mean and variance of each feature across the examples in a batch. Layer normalization computes them across all channels or hidden units of a single example. Layer norm does not depend on batch size and behaves the same in training and inference, which suits transformers and recurrent networks.
Should batch normalization go before or after the activation?
The original paper put it before the activation, right after the linear or convolutional layer, and that is the most common choice. Placing it after the activation also works and sometimes performs slightly better. The choice rarely changes results much.
Can I use batch normalization and dropout together?
You can, but they can interfere: dropout changes the variance of activations between training and inference, which shifts the statistics BN relies on. Networks that use BN often need little or no dropout. If both are used, dropout is usually placed after the last BN layer.
Why does my model perform worse in evaluation mode with batch norm?
In evaluation mode BN uses running averages instead of batch statistics. If those averages are poor, for example after very few training steps, after fine-tuning on different data, or with a momentum set too low, outputs shift. Recomputing the running statistics on training data usually fixes it.
Related explainers
- Feature Scaling — Why and how to normalize features for faster convergence
- Vanishing & Exploding Gradients — Why deep networks struggle and how to fix it
- Weight Initialization — Xavier, He, and why random weights matter
- Activation Functions — Why networks need non-linearity to learn
- Convolutional Neural Networks — How CNNs see and understand images
- Skip Connections & ResNets — Residual learning and why deeper networks work
References
- Ioffe & Szegedy (2015), "Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift"
- Santurkar et al. (2018), "How Does Batch Normalization Help Optimization?"
- Zhang et al., "Dive into Deep Learning", section 8.5: Batch Normalization
Last updated