Summary
L2 adds a penalty to the objective. Decoupled weight decay shrinks parameters outside the optimizer’s gradient history. Their updates coincide for vanilla SGD, but that algebra does not automatically extend to momentum or Adam.
Task: start two parameters at , with data gradient , learning rate , and . Freeze adaptive denominators at to isolate one step. Does routing through those denominators give the same result as direct decay?
The two formulations
L2 (penalty added to loss)
Writing , the penalized gradient is . Vanilla SGD gives the exact expansion
Weight decay (multiplicative shrink)
Direct decay uses the expression on the right. Equality requires the same learning rate, penalty convention, parameter groups, and old-state evaluation, with no momentum or adaptive scaling.
Why they diverge under Adam
Coupled L2 feeds into both Adam moment buffers. Decoupled AdamW feeds only into them. The history itself changes, not merely a final division.
For the frozen-denominator fixture, isolate the paths without updating moments:
| Quantity | Coordinate 1 | Coordinate 2 |
|---|---|---|
| Coupled data-plus-penalty step | ||
| Coupled next parameter | ||
| Direct decay | ||
| Decoupled data step | ||
| Decoupled next parameter |
The equal weights receive equal fractional direct decay despite unequal adaptive denominators. This illustration is not a complete coupled-Adam trajectory; real coupled penalties also change both moments.
Learning objective
Adam rescales coupled L2 through its moments; AdamW applies decay directly
Derivation
Follow λθ: through Adam's denominator in L2, around it in AdamW.
Which route changes if the preconditioner grows from one to ten?
For AdamW, compute corrected moments from the data gradients and evaluate both contributions against the old parameter:
Epsilon is outside the square root in this convention. Shrinking an already updated parameter instead introduces a cross-term; it is not the displayed update.
Remove adaptive scaling
New task: replace denominators with , without momentum. Picture and change: both paths reduce to the vanilla-SGD expansion. Check: both produce . Use when: the actual optimizer satisfies those assumptions, not merely because its name contains SGD.
Exempt one parameter
New task: exclude coordinate two from direct decay while retaining its data gradient. Picture and change: set only its shrink contribution to zero. Check: the decoupled result becomes , instead of . Use when: the architecture explicitly exempts that parameter role; tied tensors must not receive duplicate updates.
Failure and transfer
With momentum, even zero current data gradient can leave a nonzero history-driven update. The vanilla proof cannot identify that movement with direct shrinkage. With zero adaptive updates, cumulative decay is , so the schedule matters.
Reconstruct: what happens when halves from at , ?
Answer
One direct-decay step changes from to . The decay exposure halves for that step; this says nothing about stored-gradient movement.
Empirical impact
Loshchilov and Hutter distinguish decoupled decay from adaptive L2 and report experiments. Their results are not a guarantee of improved generalization on every architecture or training regime. Compare tuned coefficients and schedules under a matched evaluation contract.
What to skip
Review parameter roles rather than applying a universal no-decay list. Biases and normalization scales are often treated separately; embedding tables are usually matrices, not one-dimensional parameters. An embedding can also be tied to an output projection, so membership must follow tensor identity. Assign every trainable parameter exactly once and retain the architecture’s chosen exclusions.
Common pitfalls
- Inspect the installed API’s decay option; some Adam implementations expose a decoupled mode.
- Loss reduction conventions change the relative scale of an objective penalty.
- A copied coefficient does not preserve exposure when step count or learning-rate schedule changes.
- The term is ordinary fractional shrinkage when ; larger products can erase or flip a parameter.
Related
- Adam and AdamW. For the optimizer-side derivation.
- Regularization. Broader survey of regularization techniques.