Back to Deep Learning Mind Map
中文·English
🧠 Deep LearningID: weight-decay

Weight Decay & AdamW

权重衰减与 AdamW
🎯Core Definition
L2 regularization adds λ2θ22\frac{\lambda}{2}\Vert\theta\Vert_2^2 to the loss, turning the update into θθη(L+λθ)\theta \leftarrow \theta - \eta(\nabla L + \lambda\theta); under plain SGD this is exactly equivalent to weight decay θ(1ηλ)θηL\theta \leftarrow (1-\eta\lambda)\theta - \eta\nabla L. With Adam, however, the gradient term is normalized by v^+ϵ\sqrt{\hat{v}} + \epsilon, which divides λθ\lambda\theta by the same factor, so the effective decay varies wildly with gradient magnitude — L2 and weight decay are no longer equivalent. AdamW decouples them by applying weight decay directly to the parameters: θθηλθηm^v^+ϵ\theta \leftarrow \theta - \eta\lambda\theta - \eta\frac{\hat{m}}{\sqrt{\hat{v}}+\epsilon}.
💡Use Cases
the standard generalization tool for deep networks under Adam/AdamW training, especially LLM pretraining and finetuning; interviews ask for the SGD equivalence derivation, why it breaks under Adam, and AdamW's improvement.
Key Problems Solved
constrains the parameter norm to prevent overfitting. AdamW (Loshchilov & Hutter 2019) fixes the mis-scaled weight decay under Adam: the decay coefficient is constant and independent of gradient magnitude, improving generalization (the paper reports roughly 2% lower test error) and robustness to learning-rate / weight-decay hyperparameters; LLM pretraining (e.g. LLaMA) standardly uses AdamW with weight decay around 0.01–0.1 (an order of magnitude above naive L2's 5e-4).
🎯5 High-Frequency Exam Points
1
Derive the equivalence of L2 regularization and weight decay under plain SGD: write both updates θθη(L+λθ)\theta \leftarrow \theta - \eta(\nabla L+\lambda\theta) and θ(1ηλ)θηL\theta \leftarrow (1-\eta\lambda)\theta - \eta\nabla L and state the equivalence condition.
2
Why are L2 and weight decay inequivalent under Adam? What happens when λθ\lambda\theta is divided by v^+ϵ\sqrt{\hat{v}}+\epsilon?
3
Write the decoupled AdamW update θθηλθηm^v^+ϵ\theta \leftarrow \theta - \eta\lambda\theta - \eta\frac{\hat{m}}{\sqrt{\hat{v}}+\epsilon} and explain why it generalizes better than Adam + L2.
4
Hyperparameter scale: what is typical for AdamW weight decay (0.01–0.1)? How does it relate to L2's common 5e-4?
5
Does weight decay drive weights all the way to zero? Why does it mostly constrain the norm rather than zero out parameters?
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "Weight Decay & AdamW"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Previous CardLabel SmoothingNext CardConvolution Basics

🔗 More Deep Learning Knowledge Cards

Activation FunctionsAdam & AdamWAutograd Compute GraphBatch Normalization