EasyDeepLearn

Why does AdamW work better than Adam + L2 weight decay for transformers?

hard

Answer

  • In Adam, adding λ*θ inside the gradient means weight decay gets rescaled by the per-parameter learning rate 1/sqrt(vhat)1 / \mathrm{sqrt}(v_{\mathrm{hat}}).
  • Parameters with small gradients get almost no decay; those with large ones get too much.
  • AdamW decouples: apply weight decay directly to parameters (θ ← θ    η(mhat/sqrt(vhat)  +  λθ){\theta}\; - \;{\eta} \cdot (m_{\mathrm{hat}} / \mathrm{sqrt}(v_{\mathrm{hat}})\; + \;{\lambda} \cdot {\theta})) — every parameter shrinks by η*λ uniformly.
  • Critical for transformer training.
Check yourself — multiple choice
  • AdamW is identical to Adam
  • AdamW decouples weight decay from the gradient — uniform shrinkage, works well for transformers
  • AdamW removes momentum
  • AdamW uses no ε

AdamW: apply weight decay directly to θ, not through the gradient — uniform, transformer-friendly.

#optimizers#regularization

Practise Deep Learning

214 interview questions in this topic.

Related questions