Layer-normalization epsilon
ID: layer-normalization-epsilon
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. New to topics? Read the docs here!
