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, g for the loss gradient, η for the learning rate and λ for the regularisation strength. With SGD, adding λ2∥θ∥2 to the loss gives θ←(1−ηλ)θ−ηg, which is weight decay. With Adam, the λθ term is divided by v^+ϵ, so parameters with a large gradient history are decayed less. AdamW applies −ηλθ outside the adaptive scaling.

Steps

  1. SGD: ∇(L+λ2∥θ∥2)=g+λθ, so θ←θ−η(g+λθ)=(1−ηλ)θ−ηg. L2 and decay coincide.
  2. Adam with L2: g′=g+λθ enters both moment estimates, m←β1m+(1−β1)g′ and v←β2v+(1−β2)g′2. The update is θ←θ−η m^/(v^+ϵ), where m^,v^ are the bias-corrected moments and ϵ is a small constant.
  3. So the regulariser's pull on parameter i is roughly ηλθi/v^i. Weights with large or frequent gradients are regularised less, which is not what L2 is meant to do.
  4. AdamW: compute m and v from g only, then θ←θ−η(m^v^+ϵ+λθ). The decay term shrinks every weight by the same factor, (1−ηλ), per step.
  5. 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

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?