Log inStart free
LESSON 5.14 · 5 STAGES · 2 CONTROLS · 2 CHECKSPRO · PREVIEW

LayerNorm and RMSNorm

Watch two norms slide and squeeze each example of a small tensor.


Pro lesson. Stage 1 is free to watch. Pro opens all 5 stages, 2 controls and 2 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 5.14 · NORM BAYLAYERNORM · EXAMPLE 3 μ 4.85 σ 2.22
01
Stage 1 of 5 · The examples
LayerNorm reads one example: its 8 features, 4 channels at 2 positions. Examples 1 and 3 share a mean but not a spread.
Explain it simply

Each lane on the right is one example from the tensor on the left. Its 8 features are 4 channels at 2 positions. Example 1 sits near 4.9 with a spread of 3.5. Example 3 sits near 4.9 with a spread of 2.2, and example 2 near −0.2.

Three lanes, one per example, each with 8 dots. The example means are 4.85, −0.21, 4.85.

features of one exampleexample mean and spreadgain γ and bias βoutput ythe other norm, or example 1 before the changegap between the two norms
ch 1ch 2ch 3ch 4p1p2p1p2p1p2p1p2−4−20246810122.74.41.00.94.34.69.911.01.80.9−2.0−2.5−3.10.12.60.55.56.52.31.67.15.47.82.6example 1μ 4.85σ 3.52example 2μ −0.21σ 1.95example 3μ 4.85σ 2.22the 3 × 4 × 2 tensor and its examplesfeature value xone example: LayerNormone channel: BatchNorm, 5.13μ₃ = 4.85ch 1ch 2ch 3ch 4p1p2p1p2p1p2p1p2−4−20246810122.74.41.00.94.34.69.911.01.80.9−2.0−2.5−3.10.12.60.55.56.52.31.67.15.47.82.6example 1μ 4.85σ 3.52example 2μ −0.21σ 1.95example 3μ 4.85σ 2.22the 3 × 4 × 2 tensor and its examplesfeature value xone example: LayerNormone channel: BatchNorm, 5.13μ₃ = 4.85
Toy: the 3 × 4 × 2 tensor of 5.13 · seeded · γ and β are example values, not trained
STAGE 1 / 5
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
μ=18∑i=18xi\sy{mu}{ink}{\mu} = \tfrac{1}{8}\textstyle\sum_{i=1}^{8} \sy{x}{data}{x_i}
μ3=18 (5.5+⋯+2.6)=38.88=4.85\mu_3 = \tfrac{1}{8}\,(5.5 + \dots + 2.6) = \tfrac{38.8}{8} = 4.85

The example mean is the average of its 8 features.

Common mix-ups

MYTHLayerNorm normalizes each channel over the batch.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
2 CHECKS · PRO
Q01If example 1 becomes 3 times larger, do its LayerNorm outputs change?

Make your guess, then test it in the diagram. All 2 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 5
Unlock the full explainer
  • 4 more stages and 2 live controls
  • 2 mix-up cards and 2 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.