Layer Normalization is a normalization method that rescales the values of all units in a layer within a single sample to mean 0 and variance 1. It was proposed by Ba, Kiros, and Hinton in 2016. Because it does not use other samples in the batch, it does not depend on batch size and performs exactly the same computation at training and inference time.
Today it is an essential component of every layer of the Transformer, and many language models such as BERT and GPT use it.
Let be the inputs to the units of a layer (the values before the activation function). The mean and standard deviation are computed as follows (Eq. (3) in the paper).
Each unit's value is then normalized, and its scale and offset are adjusted with a learned gain and bias .
and are computed per sample and shared by all units of the layer. In contrast, and take a separate value for each unit and are learned. Normalization alone narrows the range of representable values, so and allow the original scale to be restored if needed.

