Layer-normalization epsilon 2026-11-05
The positive constant in layer normalization regularizes division by the coordinate standard deviation. For coordinates, write , and . The normalized core and the full output areHere is the Hadamard product, and are fixed when studying the dependence on . This placement of , the divisor in the coordinate variance, and the elementwise layer-normalization gain and layer-normalization bias define the stabilized convention used here.[ref]
LayerNorm in the PyTorch documentation. Equation; correction=0; Parameters/eps and elementwise_affine
If all coordinates of are equal, then and : positive makes the normalized core well defined and equal to 0, so the full output is .Positive also changes the normalization away from constant inputs. The arithmetic mean of the normalized core is 0, but its normalized coordinate variance in layer normalization isThus it approaches 1 when is large, equals when , and approaches 0 when approaches 0. This formula describes the normalized core; learned, unequal coordinate gains or biases can change the coordinate arithmetic mean and variance of the full output. For , changing from to changes the core from to .
Although layer normalization is invariant under a common input shift, a fixed positive prevents exact positive scaling invariance on a nonconstant input. For ,For and fixed , this equals only when . With , the normalized core is exactly invariant for every wherever . The unstabilized scaling argument in Layer Normalization by Jimmy Lei Ba and others therefore needs this qualification when used for the stabilized formula.[ref]
Layer Normalization by Jimmy Lei Ba and others. §3, equation 3, and §5.1, equations 6–7: normalization statistics and scaling analysis
The same constant controls layer-normalization sensitivity. With the centering matrix , we have , and . Taking a derivative gives the layer-normalization Jacobian:The common-offset vector is an eigenvector with eigenvalue . For , the radial direction has eigenvalue ; a vector orthogonal to both and has eigenvalue . At a constant input, the Jacobian matrix is . These formulas give the operator norm bound for the Euclidean norm. Integrating this derivative along a line segment proves Lipschitz continuity of the normalized core with constant . The bound for the full output is multiplied by , the operator norm of the diagonal matrix of its layer-normalization gain. For , the core bound is attained in centered directions at a constant input: smaller permits larger local amplification near zero coordinate variance.
For the input family , the third coordinate of the normalized core is , with derivative . The dashed lines mark ; the forward response approaches these values for large positive or negative .
Original layer-normalization response and sensitivity for ; unit gains and zero biases.
Details. Adding the same scalar to every coordinate leaves layer normalization unchanged, provided its layer-normalization gain and layer-normalization bias are held fixed. This is an exact statement even with positive layer-normalization epsilon. Write , let be the coordinate arithmetic mean, and define the coordinate variance . For any scalar , we haveConsequently , so both the numerator and denominator of layer normalization are unchanged. Applying the same coordinatewise layer-normalization gain and layer-normalization bias preserves the equality:The positive layer-normalization epsilon is added to the coordinate variance before taking the square root.[ref]
The centering matrix makes the geometry explicit: and . Thus the common-offset direction lies in the kernel of a linear map represented by . For the normalized core , take and . Its coordinate arithmetic mean is 2 and its coordinate variance is , giving . The vector has exactly the same normalized core. An unequal coordinate shift need not be removed: instead gives .
This identifies a precise redundancy in a neural network. If the vector before layer normalization is an affine map , adding to its bias leaves the normalized result unchanged for every . A shift of the raw input by a vector produces , which need not be a common coordinate shift. The weight re-centering calculation in Layer Normalization by Jimmy Lei Ba and others uses the related transformation : its extra contribution is , which normalization removes separately for each input.[ref]
Weighted centering matrix 2026-11-05
A weighted centering matrix subtracts the same weighted mean from every component of a vector. Let satisfy and , where has every component equal to one. DefineThen and . The centered vector has zero weighted mean; its unweighted component sum need not vanish.
The projection properties follow directly from normalization:Also , so its kernel of a linear map is , its range is and its rank is . It is an idempotent matrix. For unequal weights it is generally not symmetric: it projects onto the zero-weighted-mean subspace along the constant-vector direction, an oblique projection in ordinary Euclidean geometry.
For an original example, and give and . The weighted mean is zero, while the ordinary mean is . Euclidean orthogonal projection of onto the same line instead gives .
Weighted centering and Euclidean orthogonal projection reach different points on the same zero-weighted-mean line
. Original two-coordinate example with and . The orange arrow subtracts from both components; the dashed arrow is perpendicular to the green line in the Euclidean metric. Details.If every , put . Then , so this same map is orthogonal for the inner product . It is the residual-making map for minimizing over a fitted constant , the intercept-only case of weighted least squares.[ref] Zero weights preserve the algebraic projection but make this proposed inner product degenerate. When all weights equal , the construction reduces to the usual centering matrix.

