Layer-normalization bias
ID: layer-normalization-bias
The layer-normalization bias is the learned coordinatewise offset applied after the normalized core and layer-normalization gain. Writing the core as ,The offset is a model parameter, rather than an estimate of statistical bias. The PyTorch implementation provides an optional learned additive parameter for each normalized element.[ref]
LayerNorm in the PyTorch documentation. 2.15, equation and Variables/bias; Parameters/bias and elementwise_affine
An original constant-input example isolates its effect. Choose and any positive layer-normalization epsilon. The core is zero, so for the output is exactly , regardless of the fixed gain. Its coordinate arithmetic mean is : the output of the full learned layer need not have zero mean even though its normalized core does.
For a scalar loss with incoming output gradient , the chain rule gives . For the original loss in this example, the bias gradient is therefore . If the same parameter vector is reused at several positions, their gradient contributions add.
An equal shift of every coordinate before normalization is removed, as shown in layer normalization is invariant under a common input shift. The offset here is applied after normalization and persists. When differentiating only with respect to while parameters are fixed, contributes zero to the layer-normalization Jacobian.
New to topics? Read the docs here!