batchnorm -- running mean/variance + train vs inference

Numbers flowing through a deep network drift, one layer's outputs coming out ten times bigger than another's, and that makes training slow and fragile. This step fixes it by measuring, during training, the average and the spread of each channel — the picture one filter produces — across the current batch of images and dividing them out, so every channel arrives at the next layer on a comparable scale. Batches are small and noisy, so it also keeps a smoothed running estimate of those two numbers. That is the part that surprises people: once training is over there is no batch to measure, so the frozen estimate is used instead, and the network behaves slightly differently when you use it than it did while learning.

Interactive page: Batch Normalization -- normalize each channel's activations, track a running mean/variance during training (an exponential moving average), and at inference use that tracked average instead of the batch's own statistics. Anchor: F (CNN / vision); Family F, builds on convolution.

What it shows

For one channel of a feature map (the paintable input), BatchNorm computes y = γ · (x − μ)/√(σ² + ε) + β -- but which μ, σ it uses differs by mode:

γ (scale) and β (shift) are learned per channel and let the network undo the normalization if it wants. BN does all of this independently per channel.

Drag (paint) the input to change its values and watch the running average drift to track it, and the normalized output respond; toggle train / inference; adjust momentum (EMA rate), γ, β. The training EMA animates.

Render tier

T1 (Canvas2D: the paintable input + normalized output grids, the running-statistics tracking chart).

Wiring

layout.mount + controls (shape, mode, momentum, gamma, beta, seed) + animate (the training EMA) + onPointer paint-the-input + hover. ?mode / ?shape / ?paint / ?hover hooks. Source: page.js.