AdamW › The AdamW Formulation
Language AI HandbookAll chapters AdamW › The AdamW FormulationOne section · Sections in this chapter5 / 15 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
AdamW fixes the problem by applying weight decay directly to the parameters, separate from the gradient update. The regularization term never enters the moment estimates. The moments track only the gradient signal from the loss, and the weight decay operates independently as a direct multiplicative shrinkage of the parameters.
The standard Adam update with L2 regularization computes:
where the moments and are computed from the regularized gradient .
The AdamW update decouples these components:
where:
- : bias-corrected first moment, computed from the original gradient only
- : bias-corrected second moment, computed from the original gradient only
- : the weight decay coefficient
- : the learning rate
The weight decay term is added outside the adaptive scaling. Every parameter is shrunk by the same multiplicative factor at each step, regardless of its gradient history. The adaptive learning rates only affect the gradient-based update; they have no influence on how strongly weight decay pulls each parameter toward zero.
Written out as the complete set of equations, AdamW performs these steps at each training iteration:
where:
- : gradient of the training loss, with no regularization term mixed in
- : first moment estimate, an exponential moving average of gradients
- : second moment estimate, an exponential moving average of squared gradients
- : bias-corrected first moment, compensating for the zero initialization of
- : bias-corrected second moment, compensating for the zero initialization of
- : first moment decay rate, typically 0.9
- : second moment decay rate, typically 0.999
- : numerical stability constant, typically 1e-8
- : weight decay coefficient
- : learning rate
The critical difference from Adam with L2 regularization is in the last equation. The weight decay applies uniformly: the same term acts on every parameter with the same effective coefficient, while the gradient update handles the adaptive per-parameter scaling independently.
The Geometric Interpretation
Another way to think about the difference is geometric. Adam with L2 regularization is trying to minimize a particular objective function, namely the regularized loss , but using a preconditioned gradient descent step where the preconditioner is the adaptive scaling . The preconditioning changes the effective geometry of the optimization landscape, and the L2 ball that L2 regularization defines in the original parameter space gets distorted by the preconditioner.
AdamW is doing something subtly different: it separates the geometry-distorting adaptive step for the loss gradient from the direct parameter shrinkage for weight decay. The adaptive step handles the optimization of the loss; the weight decay handles the regularization constraint. These two objectives are kept separate rather than being mixed into a single gradient computation.
This is also why AdamW has a cleaner connection to the original weight decay formulation from SGD literature. In the SGD with momentum world, weight decay was a direct multiplicative shrinkage applied to parameters. AdamW restores this interpretation in the adaptive optimizer setting, where Adam's adaptive scaling makes it impossible to achieve uniform weight decay through gradient modification alone.