Back to Deep Learning Mind Map
中文·English
🧠 Deep LearningID: batchnorm

Batch Normalization

BatchNorm 批归一化
🎯Core Definition
Batch Normalization normalizes activations along the batch axis per feature channel to combat internal covariate shift. Given input xx, compute the batch mean and variance μB=1mi=1mxi\mu_B = \frac{1}{m}\sum_{i=1}^{m} x_i, σB2=1mi=1m(xiμB)2\sigma_B^2 = \frac{1}{m}\sum_{i=1}^{m}(x_i - \mu_B)^2, normalize x^=xμBσB2+ϵ\hat{x} = \frac{x - \mu_B}{\sqrt{\sigma_B^2 + \epsilon}}, then apply a learned affine transform y=γx^+βy = \gamma\hat{x} + \beta (per-channel γ,β\gamma, \beta for CNNs; ϵ\epsilon around 1e-5 prevents division by zero).
💡Use Cases
the default for image CNNs (ResNet and successors) to stabilize training, allow larger learning rates, and reduce sensitivity to initialization and dropout; interviews focus on the train/inference statistics gap, why small batches break it, and why NLP/Transformers switched to LayerNorm.
Key Problems Solved
keeps activations at zero mean / unit variance, smoothing the loss landscape so convergence is often several times faster (training epochs can be roughly halved), with a mild regularizing side effect from batch-statistics noise. Key engineering point: training uses current batch statistics, while inference uses exponentially moving averages (EMA, momentum usually 0.1) accumulated during training — so small batches (batch=1 makes σB=0\sigma_B=0) distort the statistics and create train/inference mismatch, effectively breaking the model, an inherent weakness of BN.
🎯5 High-Frequency Exam Points
1
Write the full BatchNorm computation: how μB\mu_B and σB2\sigma_B^2 are computed, the normalization x^=xμBσB2+ϵ\hat{x} = \frac{x-\mu_B}{\sqrt{\sigma_B^2+\epsilon}}, and the role of the affine parameters γ,β\gamma,\beta.
2
Train vs inference behavior: why must inference use the running mean/variance (EMA) instead of batch statistics, and when is the EMA updated?
3
Why does BN fail with small batches? What happens at batch=1, and what problems arise from train/inference statistic mismatch?
4
Why do Transformers/LLMs use LayerNorm instead of BatchNorm? What issues does BN face with variable-length sequences and padding?
5
Why does BN speed up convergence (ICS / loss-surface smoothing)? What is its regularizing side effect, and what order is used when combining it with Dropout?
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "Batch Normalization"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Previous CardLoss FunctionsNext CardLayerNorm & RMSNorm

🔗 More Deep Learning Knowledge Cards

Activation FunctionsAdam & AdamWAutograd Compute GraphClassic CNN Architectures