NeuroNomixer logoNeuroNomixer
  • Home
  • Blog
  • Visual Guides
  • Authors
  • Contact
Sign InSign Up
NeuroNomixer logo
HomeBlogAuthorsContactPrivacy Policy

© 2026 NeuroNomixer — Built with Next.js & Tailwind CSS

Visual Guides/Batch Normalization Explained
Deep Learning

Batch Normalization Explained

See how batch normalization stabilizes activation distributions and speeds up training. Watch two neural networks race, with and without BatchNorm.

Exploration Progress0%
○ Toggle both modes○ Complete formula○ View training race

Sign in to save your progress

1

The Problem: Shifting Activation Distributions

Without normalization, activation distributions shift layer by layer as earlier layers update. The original 2015 paper (Ioffe & Szegedy) called this "internal covariate shift" and proposed BatchNorm as the cure. Why BatchNorm actually helps is still debated: later work (Santurkar et al., 2018) found it speeds up training even when covariate shift is artificially re-injected, and attributes the benefit mainly to a smoother optimization landscape. The shifting distributions below illustrate the original motivation.

Without Batch Norm: distributions shift each layer
Layer 1
μ = 0.54, σ = 0.22
Layer 2
μ = 1.28, σ = 0.74
Layer 3
μ = -0.23, σ = 1.49
Layer 4
μ = 2.50, σ = 1.76

Each layer develops a different distribution (layer 4 here has μ=2.50, σ=1.76), forcing subsequent layers to constantly re-adapt.

2

The Math: Four Steps

BatchNorm operates on a mini-batch of activations. Step through each computation to see exactly how normalization is applied.

Sample Batch (m = 5)
x1 = 1.2x2 = -0.5x3 = 2.3x4 = 0.1x5 = -1.8
1
Step 1: Compute Batch Mean
μ = (1/m) Σ xᵢ
μ = (1.2 + -0.5 + 2.3 + 0.1 + -1.8) / 5
μ = 0.2600
2
Step 2: Compute Batch Variance
3
Step 3: Normalize
4
Step 4: Scale and Shift
Step 1 of 4

Training vs. inference: the four steps above use the current mini-batch's own mean and variance. At inference time there may be no batch at all, so BatchNorm instead uses running averages of the mean and variance accumulated during training, while γ and β stay fixed at their learned values. Forgetting to switch modes (e.g. model.eval() in PyTorch) is a classic source of inference bugs.

3

Does It Speed Up Training?

The stylized curves below illustrate what typically happens when two otherwise identical networks train with and without Batch Normalization. They are constructed for teaching, not recorded from a live run.

Training Speed Comparison (Illustrative)

Loss 0.25: epoch 8 vs 14 (6 epochs faster)

Stylized loss curves illustrating the typical effect of BatchNorm; both start at the same loss. The badge above is computed from these plotted curves.

0.000.250.500.751.0015101520LossEpoch
With BatchNorm
Without BatchNorm
4

BatchNorm vs LayerNorm

Related

BatchNorm normalizes across the BATCH dimension. For transformers & NLP, Layer Normalization normalizes across the FEATURE dimension instead: it works for single samples and variable-length sequences.

BatchNorm
Normalize over batch. Good for CNNs and fully connected layers.
LayerNorm
Normalize over features. Used in every Transformer (BERT, GPT, etc.).
Before or After Activation?

In the original 2015 paper by Ioffe & Szegedy, BatchNorm normalizes the pre-activation values: the order is Linear → BatchNorm → Activation. Some practitioners instead place it after the activation (Linear → Activation → BatchNorm); both orderings appear in production code. Separately, ResNet-v2's "pre-activation" blocks (BN → ReLU → weight layer) showed that normalizing before the weight layer improves gradient flow in very deep residual networks.

← All GuidesNext Guide →