LayerNorm — layer normalization
Read "layer norm". It shifts and rescales each token's vector to have mean 0 and variance 1, then applies a learned scale and shift.
. Here and are the mean and variance of the numbers within one token's vector. So the result for one token does not depend on the other examples in the batch, unlike BatchNorm. (gain) and (bias) are learned per feature.
It keeps activations in a steady range as layers stack up. Whether it is placed before the sub-layer (Pre-LN) or after the residual addition (Post-LN) affects whether deep models need a learning-rate warmup to train.
Example
Mean 3, variance 14/3 (ignoring ε, with γ = 1 and β = 0).
Where the course uses it
Related terms
- RMSNorm — root-mean-square normalizationRead "R M S norm". It is LayerNorm without the mean subtraction and without the shift (β): divide each vector by its root mean square, then apply a learned scale.
- μ — the meanRead "mu". It is the mean (the ordinary average) of a set of numbers: add them up and divide by how many there are.
- ε — a tiny safety constant (or the CTC blank)Read "epsilon". It is a very small number added to a denominator so the division can never be by zero. In CTC (section 27.2) the same letter means something else: the blank symbol, "no character here".
- ⊙ — element-wise productRead "a times b, element-wise". Multiply two same-shaped vectors or matrices position by position. This is not matrix multiplication.