Lessons › Chapter 8: Neural networks
Batch normalization
batch normalization measures the mean and spread of each layer’s outputs for the current batch, then shifts and squeezes them to mean 0 and spread 1, just like standardizing features.
Watch it move. This lesson is interactive on Gradient Lab: every step is an animated scene you can replay.
Start the interactive lessonStep by step
Shaky training
Every training run behaves differently and progress is unsteady.
Each layer sees shifting numbers
As earlier layers learn, the numbers they pass on keep drifting: their center and spread change from batch to batch. Later layers are trying to hit a moving target.
Re-center and re-scale each batch
batch normalization measures the mean and spread of each layer’s outputs for the current batch, then shifts and squeezes them to mean 0 and spread 1, just like standardizing features.
Then let the layer adjust
Two learnable numbers (γ and β) then re-scale and shift the result if that helps. The upshot: faster, steadier training that is less sensitive to the learning rate and to initialization.
In real life: grading on a curve
Three classes take different tests: one easy, one hard, one in between. Raw scores aren’t comparable, so the teacher grades on a curve: each class is re-centered and re-scaled. Batch norm does this for every layer, every batch.
Quick check: What does batch normalization do to a layer’s outputs?
- Re-centers and re-scales them for each batch (correct)
- Deletes the largest ones
- Sorts them
It standardizes activations per batch, then applies a learnable scale and shift.
Pseudocode
for each batch of examples, at one layer:
mean = average of the activations
std = spread of the activations
normalized = (activation − mean) / std
output = γ × normalized + β # learnable re-scale and shift
Key terms
- batch normalization
- Re-centering and re-scaling a layer’s outputs for each batch so training stays stable.