Back to Deep Learning Mind Map
中文·English
🧠 Deep LearningID: layernorm-rmsnorm

LayerNorm & RMSNorm

LayerNorm 与 RMSNorm
🎯Core Definition
LayerNorm normalizes a single sample across its feature dimension, independent of the batch: for xRdx \in \mathbb{R}^d, compute μ=1di=1dxi\mu = \frac{1}{d}\sum_{i=1}^{d}x_i, σ2=1di=1d(xiμ)2\sigma^2 = \frac{1}{d}\sum_{i=1}^{d}(x_i-\mu)^2, giving y=γxμσ2+ϵ+βy = \gamma\frac{x-\mu}{\sqrt{\sigma^2+\epsilon}} + \beta. RMSNorm is a simplification that drops the centering: y=x1di=1dxi2+ϵγy = \frac{x}{\sqrt{\frac{1}{d}\sum_{i=1}^{d}x_i^2 + \epsilon}}\cdot\gamma.
💡Use Cases
the default for Transformers / NLP / RNNs (variable-length sequences make batch statistics unreliable); RMSNorm is the standard choice for LLMs such as LLaMA and Qwen (dropping mean and bias computation, roughly 7%–30% faster training). Interviews ask why LN is batch-independent, why RMSNorm is sufficient, and Pre-Norm placement.
Key Problems Solved
removes the dependency on the batch — works at batch=1 and avoids padding pollution on variable-length sequences. Why omitting centering still works: recentering/rescaling invariance is inherent per-layer, and the mean term is absorbed by subsequent residual layers; the cost is weaker regularization than BN (no cross-sample statistical noise).
🎯5 High-Frequency Exam Points
1
Write the LayerNorm formula y=γxμσ2+ϵ+βy = \gamma\frac{x-\mu}{\sqrt{\sigma^2+\epsilon}}+\beta, state which axis it normalizes over, and why it is independent of batch size.
2
How does RMSNorm differ from LayerNorm, why does removing the mean matter little, and what does it save in LLMs (compute / reported speedup)?
3
The role of γ\gamma and β\beta in LN: what happens if they are removed, and why are they needed to restore representational power?
4
Pre-Norm vs Post-Norm: why do modern Transformers use Pre-LN (training stability and the residual gradient path)?
5
Why must RNNs/variable-length sequences use LayerNorm rather than BatchNorm? Compare their batch dependency and padding handling.
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "LayerNorm & RMSNorm"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Previous CardBatch NormalizationNext CardNorm Methods Comparison

🔗 More Deep Learning Knowledge Cards

Activation FunctionsAdam & AdamWAutograd Compute GraphClassic CNN Architectures