Skip to content
StackDecode
AI & ML Atlas
Neural NetworkstechniqueInteractive simulation

Layer Normalisation

Normalises across the features of one example instead of across the batch.

The idea

For each example separately, subtract the mean and divide by the standard deviation computed over its own features. It does not depend on batch size and behaves the same in training and inference, which is why transformers and RNNs use it.

y = γ · (x − μ)/√(σ² + ε) + β (μ, σ over features)

Watch it run

This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.

2.910.710.514.420.5-1.56.112.715.717.30.87.56.415.515.7-1.19.78.91915.7-5.112.67.72016.8-4.814.50.92512.9features →samples ↓
  • positive
  • negative

The same numbers. Layer norm treats each sample (row) on its own, so it does not depend on the batch.

step:
raw
1/4

Layer norm statistics come along each row (across features).

Step by step

  1. 1For one example compute the mean and variance over its features.
  2. 2Normalise each feature.
  3. 3Apply a learnable gain and bias.

Where it is used

Transformers and recurrent networks.

Watch out for

Slightly less effective than batch norm for CNNs.

Related