Layer Normalization

The paper introduced normalization over hidden units within a single example, avoiding dependence on mini-batch statistics.

Metadata

FieldValue
PaperLayer Normalization
AuthorsJimmy Lei Ba, Jamie Ryan Kiros, Geoffrey E. Hinton
Year2016
VenuearXiv preprint
arXiv1607.06450
PDFauthor PDF
Statusverified

Question

Batch Normalization made normalization a standard deep-learning component, but it depends on mini-batch statistics. That is awkward for recurrent networks, variable-length sequences, online inference, and settings where batch size changes between training and deployment.

Layer Normalization asks:

The architectural issue is the axis over which statistics are computed. If the statistics use other examples in the mini-batch, the layer has batch-dependent behavior. If the statistics use hidden units within the current example, the layer can behave the same way in training and inference.

Main Claim

LayerNorm normalizes across hidden units within a layer for each example, making the computation independent of mini-batch composition and consistent between training and inference.

For a hidden vector :

The learned parameters and restore representational flexibility after normalization.

The durable architecture claim is:

Architecture Contract

ItemContract
Inputhidden vector, token embedding, recurrent state, or residual-stream vector
Outputsame shape, normalized over feature/hidden dimension
Statisticsmean and variance from the current example/token
Train-time behavioruses current input statistics
Inference behaviorsame formula as training
Learned parametersusually per hidden feature
Stateno running mean or running variance
Inductive biasstabilize feature scale inside each example

For a sequence tensor , Transformer-style LayerNorm usually treats each token independently:

The normalized axes are therefore the feature dimensions, while batch index and token index remain separate.

Axis Contract

The main difference between normalization families is not the formula shape, but the axis:

MethodStatistics OverKeeps SeparateTrain/Eval Difference
BatchNormbatch and often spatial axeschannel/feature axisyes, running stats at eval
LayerNormfeature axis inside one example/tokenbatch and token positionsusually no
[[papers/architectures/root-mean-square-layer-normalizationRMSNorm]]feature axis, RMS onlybatch and token positions
GroupNormgroups of channelsbatch and spatial positionsusually no
InstanceNormspatial axes per example/channelbatch and channelusually no

Writing just “normalization” is incomplete. A correct architecture note should say which axis provides statistics and whether inference uses stored state.

Method

LayerNorm is inserted as a differentiable layer:

or inside a block:

The normalization can be applied to:

  • recurrent hidden state;
  • feed-forward hidden units;
  • Transformer residual stream;
  • token embeddings before attention or MLP blocks;
  • final representation before a task head.

Unlike BatchNorm, LayerNorm does not require running estimates:

instead of:

This makes it easier to use for autoregressive inference and variable batch sizes.

Block View

ComponentRoleArchitecture Implication
Per-example meancenters the hidden vectorremoves common feature offset within one token/example
Per-example variancecontrols hidden-vector scalestabilizes feature magnitude
numerical stabilityimportant for low-variance vectors and mixed precision
learned scaleallows each feature to recover useful amplitude
learned shiftallows each feature to recover useful offset
Placementpre/post/sandwich/final normchanges gradient path and depth stability

LayerNorm is therefore not just a preprocessing step. It is part of the residual block contract.

Evidence Reading

The original paper evaluated LayerNorm in settings where BatchNorm was less natural, especially recurrent neural networks.

ClaimEvidence TypeWhat It SupportsCaveat
LayerNorm stabilizes hidden dynamicsrecurrent-network experimentsper-example normalization helps sequence modelsoriginal scale is much smaller than modern LLMs
LayerNorm avoids batch dependencemethod definition and experimentsbehavior is not tied to mini-batch compositionfeature-axis choice still affects representation
LayerNorm can speed trainingcomparisons to unnormalized baselineshidden-scale control improves optimizationlater recipes add residual design, warmup, Adam variants
LayerNorm fits online/recurrent useno running batch statisticsconsistent train/eval computationnot always best for CNN feature maps

The paper should be read as an axis-change paper: normalize across hidden units of the same example rather than across examples.

LayerNorm In Recurrent Networks

For a recurrent update:

LayerNorm can normalize the pre-activation:

or normalize components inside gated recurrent units. For LSTM, gate logits can be normalized before applying sigmoid/tanh:

The point is that recurrent models process one time step at a time, so batch statistics can be unstable or inconvenient. LayerNorm uses the current hidden vector, so it is more natural for causal, online computation.

LayerNorm In Transformers

LayerNorm became central after Attention Is All You Need. A Transformer block is usually built from residual branches:

Normalization placement determines whether the residual stream has a clean identity path.

Post-norm:

Pre-norm:

Pre-norm often improves depth stability because gradients can pass through the residual stream without always going through the normalization Jacobian. Post-norm normalizes the output of each residual addition, but can be harder to train at depth.

This means that a Transformer paper is underspecified if it only says “uses LayerNorm.” It should say:

  • pre-norm, post-norm, sandwich norm, or final norm;
  • LayerNorm or RMSNorm;
  • whether normalization has bias;
  • whether normalization parameters receive weight decay;
  • whether residual branches are scaled or gated.

Pre-Norm vs Post-Norm

PlacementFormulaPractical Reading
Post-normoriginal Transformer style; normalized block output
Pre-normcommon in deep modern sequence models; easier gradient path
Sandwich normextra stabilization, extra compute
Final norm before headnormalizes final residual stream

The placement can change training stability as much as many named architecture modifications. When comparing models, norm placement is part of the architecture.

LayerNorm vs BatchNorm

DimensionLayerNormBatchNorm
Statisticshidden/features in one example/tokenexamples and often spatial positions
Train/eval formulausually sameusually different
Running statenonerunning mean and variance
Batch-size sensitivitylowhigh
Common domainTransformers, RNNs, sequence modelsCNNs and residual vision models
Cross-example couplingnone through statisticsyes during training
Deployment riskmostly numerical/placementtrain/eval mode and stale stats

LayerNorm is usually the safer default for sequence models because each token can be normalized independently of the batch.

LayerNorm vs RMSNorm

RMSNorm removes mean subtraction:

Compared with LayerNorm:

DimensionLayerNormRMSNorm
Mean subtractionyesno
Scale normalizationvariance/stdroot mean square
Parametersusually often only
Costslightly higherslightly lower
Common useclassic Transformers, BERT-era modelsmany modern decoder LLMs

RMSNorm is not a different architecture family; it is a normalization variant that changes the centering and parameter contract.

Gradient And Scale Intuition

LayerNorm makes the block less sensitive to absolute feature scale. If is multiplied by a positive scalar , then:

up to and affine parameters. This gives a form of scale invariance. But LayerNorm also changes gradients because the output depends on all features in the normalized vector.

The Jacobian is not diagonal: each output feature depends on the vector mean and variance. This couples feature dimensions within the same token/example. That coupling is useful for scale control, but it means LayerNorm is not just a per-feature rescaling.

Implementation Notes

Important details to check:

DetailWhy It Matters
normalized shapedefines exactly which axes are normalized
epsilonaffects numerical stability and low-variance behavior
affine parameters can be enabled or disabled
bias choicesome modern norms omit bias
dtypevariance computation can be sensitive in low precision
placementpre/post/sandwich/final norm changes optimization
weight decaynorm parameters are often excluded
fused kernelsaffect speed, memory, and numerical behavior

For , LayerNorm(d) normally normalizes the last dimension. But if tensors are laid out differently, the normalized shape can change the semantics.

Common Misreadings

”LayerNorm is just BatchNorm without batches”

Not quite. It changes the axis, removes running-stat state, and changes what information is coupled during normalization.

”LayerNorm always improves models”

It often stabilizes training, but the best normalization depends on architecture, modality, depth, batch size, optimizer, and placement.

”Pre-norm and post-norm are minor implementation details”

They change gradient paths through residual stacks. For deep Transformers, this is architecture-level behavior.

”LayerNorm explains Transformer performance by itself”

LayerNorm is one component. Transformer performance also depends on attention, MLPs, residual connections, positional encoding, optimizer, data, scale, and training objective.

What To Check In Architecture Papers

  • Which normalization is used: LayerNorm, RMSNorm, BatchNorm, GroupNorm, or none?
  • Which axes are normalized?
  • Is the block pre-norm or post-norm?
  • Is there a final norm before the output head?
  • Are present?
  • Are norm parameters excluded from weight decay?
  • Is reported?
  • Does the baseline use the same normalization placement?
  • Are claims about architecture separated from training-stability changes?
  • Does the model use fused or approximate normalization kernels?

Why It Still Matters

LayerNorm became one of the default building blocks for sequence modeling. It sits behind:

For an architecture paper shelf, LayerNorm is essential because many later architecture claims are partly claims about stable residual streams.

Limitations

  • LayerNorm does not use batch statistics, which can be a disadvantage in some CNN regimes where batch/spatial aggregation is useful.
  • It couples feature dimensions within each token/example.
  • It can hide scale problems without solving deeper optimization or initialization issues.
  • Its effect depends heavily on placement in residual blocks.
  • The original paper predates large pre-norm Transformers, so modern conclusions require reading later work too.
  • Low-precision implementations can differ numerically across kernels and frameworks.

Connections