Two textbooks tell you "L2 regularization" and "weight decay" are the same thing. With plain SGD, they're right. Plug either one into Adam, and they quietly stop agreeing.
Two weights, and , start identical. The only difference is their optimizer history: has barely been updated (small accumulated squared gradient ), has been updated constantly (large ). Watch what the same does to each under the two decay schemes.
L2 regularization is usually implemented by adding to the gradient before the optimizer's update rule divides by . Weight decay (as in AdamW) skips that division entirely:
- — the learning rate.
- — the regularization strength.
- — the current weight value.
- — Adam's accumulated squared-gradient history for this parameter.
- — a tiny constant that keeps the division well-defined.
- Plain SGD: v is effectively 1 for every parameter
SGD has no per-parameter adaptive scaling, so both formulas reduce to the same thing: . There's no distinction to make — this is why the two terms got used interchangeably for years.
- Adam: v varies wildly per parameter
A parameter with a small (rarely updated) gets divided by a small number, so comes out close to — full-strength regularization. A parameter with a large (frequently updated) gets divided by a large number, so its coupled decay shrinks toward zero no matter how large is.
- Decoupled decay never looks at v
doesn't reference at all — every parameter decays by the same fraction of itself, exactly matching the original intent of "shrink every weight a little."
Push up. The two coupled bars (L2-in-Adam) spread apart — 's decay grows fast, 's barely moves. The two decoupled bars stay stacked on top of each other the entire time, because decoupled decay was never looking at each parameter's gradient history in the first place.
- Same λ = 0.5, two parameters
With :
- has (so ): coupled decay is — half the weight, in one step.
- has (so ): coupled decay is — twenty times smaller, for the identical .
- Decoupled decay doesn't care
At that same , decoupled decay gives both parameters exactly — a fixed 5% shrink, independent of how often either parameter has been updated.
- Why this matters in practice
Rarely-updated parameters (think: embeddings for infrequent tokens) get crushed by coupled L2 long before frequently-updated ones feel any pull — an accident of optimizer bookkeeping, not a deliberate regularization choice. Decoupled decay applies the same regularization strength everywhere, which is why AdamW dropped coupled L2 in favor of it.
Raise λ until coupled L2 would shrink w₁ by at least 50% in a single step, while decoupled decay on that same w₁ stays under 10%.
"Weight decay" and "L2 regularization" are the same formula only when there's no adaptive per-parameter scaling to interact with. The moment you add one — Adam, RMSProp, anything that divides by an accumulated gradient statistic — coupling the two lets the optimizer's own bookkeeping decide how much regularization each parameter actually receives. Decoupling them, as AdamW does, restores to meaning what it says. The next few chapters look at other places training goes wrong not because the math is broken, but because a hyperparameter interacts with something it was never designed to interact with — starting with the learning rate itself.