Normalization inside a neural net is almost embarrassingly simple: take some numbers, subtract their mean, divide by their standard deviation, then rescale with two learnable knobs. Every normalization layer you have ever used does exactly that. The only thing separating BatchNorm from LayerNorm is one deceptively small decision: which numbers do you average over?

Get that decision right and the layer drops straight into a Transformer. Get it wrong and your model falls apart the moment you feed it a single example.

The shared recipe

Both layers compute the same two lines:

xhat = (x - mean) / sqrt(var + eps)