Why is L2 regularisation not the same as weight decay when training with Adam, and what does AdamW change?
Deep learning, Optimisation of deep networks
Level L4 Advanced. Length Medium. Nature Th+Mat Both.
What's being asked
Whether you can show that L2 regularisation and weight decay are equivalent for SGD, but not under Adam's per-parameter scaling.
Key idea
Write for the parameters, for the loss gradient, for the learning rate and for the regularisation strength. With SGD, adding to the loss gives , which is weight decay. With Adam, the term is divided by , so parameters with a large gradient history are decayed less. AdamW applies outside the adaptive scaling.
Steps
- SGD: , so . L2 and decay coincide.
- Adam with L2: enters both moment estimates, and . The update is , where are the bias-corrected moments and is a small constant.
- So the regulariser's pull on parameter is roughly . Weights with large or frequent gradients are regularised less, which is not what L2 is meant to do.
- AdamW: compute and from only, then . The decay term shrinks every weight by the same factor, , per step.
- Consequences: better generalisation in practice, and the best depends less on the learning rate. AdamW is the default for training transformers. Biases and normalisation gains are usually excluded from decay.
Common mistakes
- Saying L2 and weight decay are the same for every optimiser.
- Thinking AdamW changes how and are computed, beyond removing from them.
- Forgetting that most implementations (e.g. PyTorch) still multiply by the learning rate, so a learning-rate schedule also scales the decay.
How long your answer should be
About 3 minutes; three update equations.
Last checked on 4 December 2026.
Read this
Previous in Deep learning: Why do residual connections make very deep networks trainable?
Next in Deep learning: What does the universal approximation theorem say for networks with one hidden layer, what does it not guarantee, and why are deep networks used anyway?