Visual walkthrough — Layer normalization
We work with one example: a single list of numbers coming out of a layer. Call that list
Reading the symbols:
- (bold) — the whole list, one example's worth of numbers.
- — the -th number in that list. The little is just a counter: is the first, the second.
- — how many numbers are in the list (the number of features / units). In our running example .
That's all the notation you need to start. Everything else we build.
The page follows four moves, kept as separate numbered steps so you always know when enters: Centre (Step 3), Squeeze (Step 5), Guard with (Step 6), Restyle (Step 9).
Step 1 — Lay the raw values on a number line
WHAT. Take one example and simply plot each value as a dot on a horizontal axis.
WHY. Before we do any arithmetic, we must see the problem: these four numbers sit off to one side (all positive, centred near 2.5) and are spread out by a certain amount. LayerNorm's whole job is to slide this cluster to sit on zero and squeeze it to a standard width. You can't appreciate a fix you can't picture.
PICTURE. The four lavender dots below are the raw . Notice they are not centred on 0 — their middle is off to the right.

Step 2 — Find the centre: the mean
WHAT. Add all the numbers and divide by how many there are.
Symbol by symbol:
- — the big Greek "S" (, sigma) means sum. Start at , go to , add every : here .
- — divide that total by the count , giving .
- (Greek "mu") — the balance point of the dots, the value they average to.
WHY. To recentre the cluster we first need to know where its centre is. The mean is exactly "the place where the dots balance." Nothing fancier will do: it is the unique number whose deviations sum to zero (we use that fact in Step 4).
PICTURE. The coral line marks — it sits right in the middle of the lavender dots, like the pivot of a see-saw.

Step 3 — Slide everything to zero (subtract )
WHAT. Replace each by its deviation from the mean:
For , :
- — "how far is this dot from the centre, and on which side?" Negative = left of centre, positive = right.
WHY. We want the finished output to have mean zero (the parent note's Step 1 goal: "so the layer isn't biased high or low"). Subtracting the same number from all of them slides the whole cluster left until its centre lands on 0 — it changes position but not spread. This is the Centre move.
PICTURE. The cluster has shifted so the coral line (now at 0) passes through its middle. The distances between dots are unchanged — only the whole group moved.

Recall Quick check: do the deviations balance?
Sum of deviations ::: . This is always true — it's why is the right centre.
Step 4 — Measure the spread: variance and standard deviation
WHAT. Square each deviation, then average the squares: and define the standard deviation as its square root:
For our deviations :
- squares: ,
- average: ,
- root: .
Symbol by symbol:
- — squaring does two jobs: it kills the sign (left and right both count as "far"), and it punishes far dots more than near ones.
- (Greek "sigma", squared) — the average squared distance; a single number for "how wide is this cluster."
- — the standard deviation: the width put back into the same units as the data (here ). This is the number we will divide by in Step 5.
WHY squaring and not, say, absolute value? Squared distance is the measure that makes the rescaling in Step 5 give exactly variance 1 (we prove this in Step 7). It's the natural partner of the mean.
PICTURE. Each dot's distance to the centre is drawn as a bar; its squared length is the shaded square. (mint) is the "typical" half-width of the cluster.

Step 5 — Squeeze to standard width: divide by
WHAT. Divide every centred value by the standard deviation. We first write the ideal squeeze (no safety term yet), because it's the cleanest to picture:
With :
Symbol by symbol:
- numerator — the already-centred value from Step 3.
- — the cluster's width from Step 4. Dividing by it rescales the whole cluster to a standard width of 1.
- ("x-hat") — the standardized value: mean 0, variance 1.
WHY. Step 3 fixed the position; this Squeeze fixes the size. After both, every example's row looks the same shape regardless of how big or lopsided it started — that stability is exactly what the next layer wants. (Step 6 will patch the denominator so a flat row can't break this.)
PICTURE. The wide green cluster (before) is squeezed to the narrow one (after), now spanning a standard width. Same shape, standardized scale.

Step 6 — Guard the denominator: add
WHAT. Replace the bare width by a guarded width , giving the real LayerNorm formula:
Symbol by symbol:
- (Greek "epsilon", e.g. ) — a tiny positive number added inside the square root before taking the root. If a row were nearly constant, and Step 5 would divide by ~0 → NaN. Adding keeps the denominator safely above zero.
WHY. This is the Guard move — the single reason the formula in Step 5 is production-safe. It costs almost nothing on normal rows and rescues the degenerate ones (Step 8).
PICTURE. Same squeezed cluster as Step 5, but the width bar is now — a whisker wider than , so the dots sit a whisker inside width 1.

Step 7 — Prove the ideal output is mean 0, variance 1
WHAT. Check the two guarantees on the standardized row, in the ideal case (Step 6 already showed what changes).
Mean of :
Variance of (its values are already centred, so variance = mean of squares):
WHY. This is the payoff: with , not "roughly" but exactly mean 0 and variance 1. This is why we chose squared distance in Step 4 — it makes the second line collapse to . Add the real and you get instead, as Step 6 showed.
PICTURE. Numerically: our sums to and its mean square is . The green bars land symmetrically about 0 with the mint width equal to 1.

Step 8 — The degenerate case: a flat row
WHAT. What if every feature is the same, e.g. ?
- , every deviation , so .
- Without : → undefined / NaN.
- With (the Step 6 guard): . Safe.
WHY. A constant row has no spread to standardize — there's genuinely nothing to normalize, and the honest answer is "all zeros." The lets the formula reach that answer instead of exploding. This is not a corner you can skip: near-constant rows really occur (dead activations, padding tokens).
PICTURE. Left panel: all dots stacked at one value, coral mean line runs right through them, width . Right panel: with , the output collapses cleanly to instead of blowing up.

Step 9 — Restore freedom: the learnable knobs
WHAT. Give each feature its own scale and shift :
With , on :
Symbol by symbol:
- (Greek "gamma") — multiplies : a new width knob (here ×2 makes the cluster twice as wide).
- (Greek "beta") — added on: a new centre knob (here +1 slides the cluster to mean 1).
- — the value that actually leaves LayerNorm and enters the next layer.
WHY. Mean 0 / variance 1 is a good starting point, but sometimes a bad ending point — e.g. the next activation function (like tanh) may want a wider input range. This Restyle move lets the network choose the final scale and shift by gradient descent. Crucially, if not normalizing is best, the net can learn and to exactly undo Steps 3–6. So LayerNorm can never make things strictly worse.
PICTURE. The mint standardized cluster (mean 0, width 1) is stretched ×2 (butter) and slid +1 to become the final butter cluster centred at 1.

The one-picture summary
The whole pipeline is four moves on one row of numbers: Centre (subtract , Step 3), Squeeze (divide by , Step 5), Guard (add under the root, Step 6), Restyle (apply , Step 9). Because every step uses only this row's statistics, LayerNorm never touches other examples — that's why it's identical at train and test time and works with a batch of size 1 (Transformers, RMSNorm, Residual connections all lean on this).

Recall Feynman: the walkthrough in plain words
You have one student's row of quiz scores, say . First you find where the scores balance — the average, (the coral line). You slide every score left by so the average sits at ; now some are negative, some positive, and they cancel out (Centre). Then you measure how wide the spread is (the mint width ) and divide every score by it, so the spread becomes about — no matter whether the original scores were or , the squeezed picture is the same (Squeeze). To be safe you add a tiny under the square root so that a student whose scores are all identical can't cause a divide-by-zero; the honest answer for them is just zeros (Guard). Because of that the spread ends up a hair below 1 rather than exactly 1 — — which no one can tell apart from 1. Finally two knobs, and , let the network stretch and slide the tidy row to whatever final scale the next layer prefers — or even put it back exactly as it was (Restyle). And the beautiful part: you never once looked at any other student. Each row fixes itself.