What is batch normalisation?
Batch normalisation is a technique that speeds up and stabilises training by normalising a layer's activations with the mean and variance of the current batch during training, then applying a learnable scale and shift.
It is also called BatchNorm or batch normalization. It differs from layer normalisation in where statistics come from: batch normalisation normalises each feature across the examples in a batch, while layer normalisation normalises each example across its own features and does not depend on the batch. Transformers therefore use layer normalisation or RMSNorm, while CNNs commonly use batch normalisation.
- Topic
- Machine learning, models and training
- Also known as
- BatchNorm, batch normalization
- Origin
- 2015, Ioffe and Szegedy
How batch normalisation works
- During training the mean and variance of each feature or channel are computed over the mini-batch.
- Activations are normalised with these statistics, then learnable scale and shift parameters are applied.
- A running average of the statistics is kept throughout training.
- At inference these fixed averages replace batch statistics, so one example's result does not depend on its neighbours.
In more detail
The formula, ε and learnable γ and β
For each feature or channel in a mini-batch, batch normalisation computes the batch mean and variance, subtracts the mean and divides by the square root of the variance (a small ε in the denominator prevents division by zero), then applies learnable γ (scale) and β (shift) parameters. Without γ and β, forcing zero mean and unit variance could restrict the representational power of later non-linear layers.
Synchronised batch normalisation in multi-GPU training
In multi-GPU distributed training (such as DistributedDataParallel), standard BatchNorm computes statistics separately on each GPU's local micro-batch, which degrades accuracy when per-GPU batch sizes are tiny. Synchronised BatchNorm (SyncBatchNorm) aggregates mean and variance across all GPUs at the cost of extra inter-GPU communication.
Layer folding at inference and the eval() trap
At inference, batch normalisation becomes a fixed linear transformation and is commonly fused directly into the preceding convolutional or linear layer (Conv-BN folding), eliminating runtime overhead. Conversely, in frameworks like PyTorch, developers need to call model.eval() rather than relying solely on torch.no_grad(), as no_grad disables gradient tracking without freezing running BatchNorm statistics.
Commonly confused terms
| Term | How it differs |
|---|---|
| Group normalisation | Group normalisation divides channels into groups and normalises within each group per sample, remaining independent of batch size while preserving spatial channel structure, often replacing BatchNorm in object detection and segmentation trained with small batches. |
| RMSNorm | RMSNorm (Root Mean Square Layer Normalisation) drops mean-centring and rescales activations solely by their root-mean-square norm, cutting computational overhead; it is widely used in current LLMs. |
Why batch normalisation matters for on-premises AI
Batch normalisation lets deep convolutional networks train with higher learning rates and fewer tuning trials, cutting GPU time for in-house training. With small batch sizes the statistics become noisy, so when memory forces small batches layer or group normalisation fits better. Forgetting to switch the model to inference mode, which leaves training statistics in production, is a common mistake that makes results inconsistent.
A manufacturing plant adds batch normalisation to a convolutional network for its quality control cameras; training converges in fewer trials and the model runs in inference mode with fixed statistics in production.
Common questions
What is the difference between batch and layer normalisation?
Batch normalisation computes statistics across the examples in a batch and is sensitive to batch size. Layer normalisation normalises each example within itself, which is why language models prefer it.
Why does batch normalisation behave differently in training and inference?
In training it uses the current batch's statistics. At inference it uses fixed averages gathered during training so a single example gives consistent results.
Related terms
- Layer normalisation
- Batch size
- Root Mean Square Layer Normalisation
- Learning rate
- Deep learning
- Convolutional neural network
Sources
In the glossary: Glossary, A to C