Normalizer

Experimental alpha. Expect breaking changes and major bugs. Your feedback is much appreciated.

Normalizer

Rescales each vector to a mean of 0 and a variance of 1, then applies a learned gain and a learned offset.

layer normalization

Shapes

[…×C] in, the same shape out. Each vector is normalized over its last size.

Parameters

2 × C. ε is 1e-5.

In PyTorch

self.norm1 = nn.LayerNorm(C)
h = self.norm1(x)

Notes

Put one at the start of each branch, before attention or the feed-forward block, and one before the final Linear Layer. This pre-norm layout is GPT-2's, and nearly every model since uses it. The RMS Normalizer does the same job with less.

Making it

The Fabricator makes it from a photomask of Layer Norm: verify the spec on a Bench, or find a salvaged mask in the ruins, which makes it unfused. See The Bench and the Fabricator.