Layer normalization

Normalization · node type · LayerNormalization, SimplifiedLayerNormalization, ReduceMean

Rescales each token’s features to zero mean and unit variance, then applies a learned gain and bias.

Also called LayerNorm, RMSNorm, SimplifiedLayerNormalization

Figure 1. Layer normalization inside Ask a question about a table, a real model in WeightSpace. The 5 outlined nodes are Layer normalization; select any node for its shapes and parameters.

What it does

Layer normalization looks at the feature vector of a single example (or a single token) and subtracts its mean and divides by its standard deviation. A learned per-feature gain γ and bias β then restore whatever scale the next layer needs. Unlike batch normalization it does not depend on other examples in the batch, so it behaves the same in training and in use, and works for sequences of any length. Transformers place one around every attention and feed-forward block. Older exporters spell it out as ReduceMean, Sub, Pow, ReduceMean, Add, Sqrt, Div, Mul, Add. RMSNorm skips the mean subtraction.

Formula

μ = (1/D) Σi xi, σ2 = (1/D) Σi (xi − μ)2yi = γi · (xi − μ) / √(σ2 + ε) + βi

Shapes and parameters

Shapes
Any shape [..., D] in, the same shape out; γ and β are [D].
Parameters
2 × D: a gain and a bias per feature. With D = 768: 1,536.
Used for
Every transformer block (BERT, ViT, CLIP, Marian), the mixers of TinyTimeMixer, and many audio models.

Figure 2. The typed ports of Layer normalization, in the same format as every model drawing. Letters such as N or C stand for any size.

In WeightSpace

A few catalog transformers expose single LayerNorm parameters as their editable values: the final gain of a question-answering model, and final LayerNorm biases of a retrieval model and an image–text model. Edits stay within ±8 of the shipped value and shift one feature of every token.