Visual explainer
Batch Normalization
How centering each batch steadies deep layers and buys bigger learning steps.
In deep feedforward networks, parameter updates in early layers cause cascading shifts in the activation distributions fed to downstream layers. This phenomenon, termed internal covariate shift, forces deeper neurons to continuously adapt to an unstable, drifting input distribution. As downstream weights chase moving statistical targets, optimization slows and training becomes vulnerable to vanishing or exploding activations.
Center, Then Even Out
Batch Normalization stabilizes intermediate representations by standardizing activations across the mini-batch dimension. For a mini-batch , the batch mean is and sample variance is (). Centering by subtracting and scaling by transforms raw inputs into standardized coordinates , enforcing zero mean and unit variance.
Reshape on Purpose
Constraining activations strictly to standard normal distributions risks trapping values within the linear regimes of activation functions like Sigmoid or Tanh. To preserve network expressiveness, Batch Normalization introduces two learnable parameters per channel: scale and shift , computing . For standardized value with learned and , the layer outputs , allowing the network to recover any arbitrary representation.
Freeze the Calm
During training, each layer tracks exponential moving averages of batch means and variances (). At test time, these running statistics are frozen. When evaluating an individual test sample, the network standardizes inputs against the fixed historical population statistics rather than requiring mini-batches, ensuring deterministic, reproducible inference for single inputs.
Stride Five Times Longer
Batch Normalization significantly improves optimization geometry. By controlling gradient magnitudes and smoothing the loss landscape's Lipschitz curvature, the network avoids ill-conditioned ravines. While unnormalized networks must crawl at cautious learning rates like to avoid divergence, normalized models glide stably with five times larger step sizes (), accelerating convergence.
Mind the Batch Size
Because Batch Normalization relies on mini-batch statistics, batch size directly affects estimation fidelity. Batches of 32 or larger provide dependable population approximations across the vertical batch dimension. When hardware memory limits batches below 32, batch statistics turn volatile; models switch to Layer Normalization, which standardizes horizontally across features within each individual sample independently of batch size.
Where It Breaks
The mathematical formulation fails entirely when the training batch size collapses to one (). A single sample equals its own mean (), producing a sample variance of zero (). Standardizing divides zero by , collapsing the activation to zero and forcing output . All input information is extinguished, completely halting forward and backward information flow.
The Quick Version
- Deep layers chase inputs that drift after every weight update.
- Mini-batch standardization enforces zero mean and unit variance.
- Learnable scale and shift restore full representational capacity.
- Frozen running statistics enable deterministic single-sample testing.
- Smoothed loss landscapes permit five-times-larger learning steps.
- Maintain batch size above 32 or switch to layer normalization.
- Single-sample training batches collapse variance to zero and fail.