Layer Normalization Takes Its Statistics From One Example
Layer normalization computes the mean and variance over all the units of one layer for one training example, so it does not need a mini-batch. Ba, Kiros, and Hinton propose it because batch normalization depends on the mini-batch size and is not obvious to apply to recurrent networks.
Their Equation 3 takes a layer's H summed inputs a₁ … a_H and computes μ = (1/H) Σ aᵢ and σ = sqrt((1/H) Σ (aᵢ − μ)²). All the hidden units in a layer share the same μ and σ, but different training cases have different ones. A learned gain and bias then apply to each unit after the normalization and before the nonlinearity. The paper says layer normalization performs exactly the same computation at training and test time, and for a recurrent network the statistics are computed separately at each time step.
Try it by hand. Let one layer's summed inputs for one example be (1, 2, 3, 6). Then μ = 3 and σ² = (4 + 1 + 0 + 9) / 4 = 3.5, so σ = 1.871. The normalized values (aᵢ − μ) / σ are −1.069, −0.535, 0, and 1.604. They sum to zero. Now multiply every input by 10: μ = 30 and σ = 18.71, and the normalized values are the same four numbers. The paper says that in a layer-normalized recurrent network this makes the layer invariant to re-scaling all of its summed inputs, which results in "much more stable hidden-to-hidden dynamics".