S3-13 · 进阶 · 单个位置的尺度稳定器S3-13 · Advanced · Per-position scale stabilizer

层归一化 · 别让一个特征把整排淹没Layer Normalization · Stop One Feature from Drowning Out the Row

one token position → normalize across its features

层归一化(Layer Normalization)对单个位置的特征做归一化,稳定各层数值尺度。这里的“层”不是把不同 token 或整个数据集混在一起。Layer normalization normalizes features within one position to stabilize scales across layers. It does not mix different tokens or an entire dataset.

01 · 同一排仪表要可比01 · Make one dashboard comparable

四个仪表里一个突然冲到 100,另外三个还在个位数:下一站还能稳定读懂吗?One of four gauges jumps to 100 while the others stay in single digits. Can the next stage read them reliably?

02 制造极端分量,再按一次 LayerNormCreate an Extreme Feature, Then Apply LayerNorm

单位置 · 跨特征one position · across features
当前均值 μCurrent mean μ
5.5
同一 token 的 4 个特征four features in one token
当前方差 σ²Current variance σ²
53.3
尺度离散程度scale spread
处理状态Processing state
RAW
原始特征raw features

画布只画同一个 token 位置的四个特征。LayerNorm 后近似均值 0、方差 1;γ、β 暂固定为 1、0。The canvas shows four features from one token position only. After LayerNorm, mean is near 0 and variance near 1; γ and β stay at 1 and 0 here.

03 LayerNorm 的 4 个零件Four Parts of LayerNorm

center · scale · tune
PART 01

单个位置One position

只取当前 token 的整排特征。Take the complete feature row for the current token.

PART 02

减去均值Subtract the mean

把这排特征的中心移到 0。Move the center of this feature row to zero.

PART 03

除以标准差Divide by spread

让离散尺度回到大致可比。Bring the spread back to a comparable scale.

PART 04

γ 与 βγ and β

可学习缩放与偏移恢复需要的表达。Learned scale and shift restore useful expressiveness.

04 最小机制:同一行先居中,再缩放Minimal Mechanism: Center One Row, Then Scale It

LN(x) = γ(x − μ) / √(σ² + ε) + β
i = (xi − μ) / √(σ2 + ε)
yi = γx̂i + β
把特征 3 拉到 60,再按 LayerNorm。原始方差暴涨,但输出仍回到稳定尺度。Push feature 3 to 60, then apply LayerNorm. Raw variance jumps, while the output returns to a stable scale.
量一行Measure one row计算 μ 与 σ²Compute μ and σ²
居中缩放Center and scale极端量不再统治尺度Extreme values stop ruling the scale
学习微调Learned adjustmentγ、β 保留表达能力γ and β preserve expressiveness

05 边界实验:四个特征完全相同Boundary Test: Make All Four Features Identical

主动制造失败Create a failure

归一化能稳尺度,不能凭空制造差异Normalization stabilizes scale; it cannot invent contrast

把四个特征都设成 7。方差为 0,ε 避免除零,但输出仍全部相同,信息差异已经不存在。Set every feature to 7. Variance becomes zero; ε prevents division by zero, but every output remains identical because no contrast exists.

尚未执行。当前特征仍有差异。Not run yet. Current features still differ.
LayerNorm 在所有 token 间取平均。LayerNorm averages across all tokens. → ✓ 它对单个位置的特征维做归一化。It normalizes across features within one position.
归一化后所有值都相同。Normalization makes every value identical. → ✓ 它重定中心与尺度,保留相对差异。It resets center and scale while keeping relative differences.
稳定数值就能补回丢失信息。Stable numbers restore lost information. → ✓ 若特征无差异,LayerNorm 不能创造内容。If features lack contrast, LayerNorm cannot create content.
06 · 一句话带走06 · One line to keep

层归一化在单个 token 的特征维内重定均值与尺度,使各层数值更稳定;制造极端值并执行 LayerNorm 就能直接验证。Layer normalization recenters and rescales features within one token, stabilizing values across layers. Create an extreme value and apply it to verify the effect.