Layer Normalization (2016) › The Solution
History of Language AIAll chapters Layer Normalization (2016) › The SolutionOne section · Sections in this chapter3 / 7 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Layer normalization addresses these challenges by computing normalization statistics across the features of each individual example, rather than across the batch dimension. This fundamental shift eliminates all batch dependencies while preserving the core benefits of normalizing activations. The technique is applied to the inputs of each layer, transforming them to have zero mean and unit variance across the feature dimensions.
The mathematical formulation is straightforward. For a layer with input vector of dimension , layer normalization first computes the mean and variance across all features:
These statistics are computed independently for each example in the batch, using only that example's features. The input is then normalized and scaled:
where is a small constant added for numerical stability. Finally, learnable parameters and are applied to allow the network to learn the optimal scale and shift:
where represents element-wise multiplication. The parameters and have the same dimension as and are learned during training, allowing the network to recover the original activations if normalization proves unhelpful for a particular layer or to adjust the scale to optimal values.
The key insight is that layer normalization computes statistics across what the paper calls the "layer," meaning all the features or dimensions of the input for a single example. For a fully connected layer, this means normalizing across all hidden units. For a convolutional layer, it means normalizing across all feature maps and spatial locations for a single example. For a recurrent layer, it means normalizing across all hidden units at each time step, independently for each example.
This approach provides several immediate advantages over batch normalization. First, it requires no batch dimension, making it applicable in settings where batch size is one or varies during training. Second, it's naturally suited to variable-length sequences because each sequence is normalized independently. Third, the statistics are deterministic for a given input, eliminating the randomness that comes from batch composition in batch normalization. This determinism makes layer normalization more predictable and easier to reason about.
The normalization operates identically during training and inference, without the need for separate modes or running averages. This eliminates a source of potential bugs and distributional shifts between training and deployment. The technique also integrates smoothly with gradient-based optimization. This provided gradient flow benefits similar to batch normalization while avoiding the complications that batch statistics introduce in recurrent settings.