For years after Adam was introduced, deep learning teams faced a stubborn split: adaptive gradient optimizers converged quickly on language and generative models, yet stochastic gradient descent with momentum kept winning on image classification benchmarks like CIFAR-10 and ImageNet. In late 2017 (published at ICLR 2019), University of Freiburg researchers Ilya Loshchilov and Frank Hutter traced much of that generalization gap to a silent mismatch in deep learning libraries: optimizers exposed a parameter named weight_decay, yet actually added an L2 penalty to the loss function.
For standard SGD, L2 regularization and true weight decay produce identical trajectories once rescaled by the learning rate (lambda' = lambda / alpha). For adaptive optimizers like Adam, feeding the L2 penalty into the gradient vector pushes the regularizer through Adam’s coordinatewise variance estimate, weakening regularization on weights with large historical gradients and coupling decay strength to the learning rate. Separating multiplicative weight shrinkage from the gradient update yields AdamW, now the standard optimizer for pretraining transformers and large language models.
- 15% relative cut in test error: at Adam’s default learning rate (
0.001), decoupling weight decay reduces test error by 15% relative compared to L2-regularized Adam on CIFAR-10 (26-layer2x96dShake-Shake ResNet, 1,800 epochs) and ImageNet32x32. - Formal inequivalence (
Proposition 2): for any optimizer with a non-scalar preconditionerM_t != kI, no L2 loss penalty(lambda' / 2) ||theta||^2can reproduce multiplicative weight decay(1 - lambda) theta_t. - Scale-adjusted penalty (
Proposition 3): under a fixed diagonal preconditionerdiag(s)^(-1), true weight decay matches minimizingf_t(theta) + (lambda' / 2) ||theta * sqrt(s)||^2, regularizing parameters with large historical gradient scales_imore strongly bysqrt(s_i)than plain L2 does. - Up to 10x faster anytime accuracy with warm restarts: pairing
AdamWwith normalized decay and cosine warm restarts (AdamWR) reaches strong test error up to 10x earlier at the first restart, while external EEG ResNet runs rose from61.34%(Adam) to72.04%(AdamW).
Why L2 regularization and weight decay diverge in Adam
The original weight decay rule from Hanson and Pratt (1988) shrinks parameters exponentially each step: theta_{t+1} = (1 - lambda) theta_t - alpha * grad f_t(theta_t), where lambda is the decay rate and alpha is the learning rate. Under plain SGD without momentum, Proposition 1 shows this is identical to minimizing the regularized batch loss f_t(theta) + (lambda' / 2) ||theta||^2, provided lambda' = lambda / alpha.
Even in SGD, that equivalence creates a tuning trap. Because lambda' equals lambda / alpha, changing the learning rate alpha manually or via a schedule silently alters effective weight shrinkage unless lambda' is retuned inversely. Subtracting decay directly in the parameter update (theta_t = theta_{t-1} - m_t - eta_t * lambda * theta_{t-1}, with schedule multiplier eta_t, shown as SGDW in Algorithm 1) breaks that tie so alpha and lambda vary independently.
In adaptive gradient methods, L2 and weight decay are not merely coupled; they are mathematically incompatible. Proposition 2 proves that for any preconditioned optimizer theta_{t+1} = theta_t - alpha * M_t * grad f_t(theta_t) with a non-scalar preconditioner M_t != kI, no L2 coefficient lambda' can reproduce (1 - lambda) theta_t - alpha * M_t * grad f_t(theta_t). Matching both updates for all theta_t would require lambda * theta_t = alpha * lambda' * M_t * theta_t, which fails whenever M_t scales coordinates unevenly.
In standard L2-regularized Adam (Algorithm 2), lambda * theta_{t-1} is added into g_t on line 6 and feeds both m_t and v_t. Dividing by sqrt(v_hat_t) + epsilon scales down the regularizer on weights with large historical gradients. Proposition 3 makes the difference concrete for a fixed diagonal preconditioner M_t = diag(s)^(-1): decoupled weight decay is equivalent to minimizing f_t(theta) + (lambda' / 2) ||theta * sqrt(s)||^2 (with lambda' = lambda / alpha). Parameters with large inverse preconditioner s_i receive proportionally stronger regularization by sqrt(s_i) than under L2, restoring uniform fractional decay across every coordinate.
Laurence Aitchison’s Bayesian filtering view of adaptive optimizers (Section 3) arrives at the same rule from first principles: tracking weights under a Gaussian transition prior P(theta_{t+1} | theta_t) = N((I - A) theta_t, Q) produces gradient preconditioning by posterior uncertainty Sigma_post, while setting A = lambda * I directly induces (1 - lambda) theta_t shrinkage in the prior, independent of per-parameter uncertainty.
Hyperparameter separability, normalized decay, and schedules
Loshchilov and Hutter evaluated 26 2x64d (11.6M parameters) and 26 2x96d (25.6M parameters) Shake-Shake ResNets (batch size 128) on CIFAR-10 and downsampled ImageNet32x32 (1.2 million 32x32 images). Three empirical findings explain why AdamW replaced L2-Adam.
First, decoupled decay makes learning rate and weight decay nearly separable. In Figure 2 (100 epochs on CIFAR-10), standard SGD with L2 regularization forms a diagonal optimal basin (alpha = 1/2 pairs with lambda = 1/8 * 0.001), so moving either hyperparameter alone hurts accuracy. Switching to SGDW rotates that basin into a vertical column around lambda = 1/4 * 0.001 to 1/2 * 0.001; even at a poor learning rate (1/1024), sweeping lambda alone finds a good minimum. For Adam, L2 regularization produced virtually no gain over lambda = 0 (~4.0% to 4.3% error) and trailed SGD, whereas AdamW opened a vertical valley around lambda = 1/4 * 0.001 to 1/2 * 0.001 and matched SGD and SGDW (~3.5% error).
Second, Adam gains substantially from global learning rate schedules. Figure 1 compares fixed learning rate, step-drop (epochs 30, 60, 80), and cosine annealing over 100 epochs. AdamW beats L2-Adam under every schedule, with cosine annealing delivering the lowest test error and cleanest separability. Extending cosine annealing with warm restarts (AdamWR, doubling cycle lengths via T_mult = 2 from initial T_{i=0}) reaches the same final accuracy while cutting time to strong anytime error by up to 10x at the first restart (Figure 4).
Third, AdamW improves true generalization, and optimal raw decay scales down with run length. Over 1,800 epochs at LR = 0.001 on 26 2x96d ResNet (Figure 3), Adam and AdamW overlap for the first half of training before AdamW achieves both lower training loss and lower test error at matched training loss values. Across CIFAR-10 and ImageNet32x32, AdamW cuts test error by 15% relative to L2-Adam, closing most of the gap to SGDWR on CIFAR-10 and matching it on ImageNet32x32. To avoid re-tuning lambda for longer budgets, Appendix B.1 defines normalized weight decay lambda = lambda_norm * sqrt(b / (B * T)) (batch size b, dataset size B, epochs T). Settings lambda_norm = 0.025 and 0.05 transferred cleanly from CIFAR-10 to ImageNet32x32 (24x more batches per epoch), whereas reusing raw CIFAR-10 lambda would over-regularize by roughly 5x. External works in Section 4.5 echoed these gains: Wang et al. (2018) trained WIDER FACE detectors nearly 10x faster, Volker et al. (2018) improved EEG accuracy from 71.37% to 73.68% (Deep4Net) and 61.34% to 72.04% (ResNet), Radford et al. (2018) adopted AdamW for GPT, and Zhang et al. (2018) confirmed decoupled decay beat L2 across SGD, Adam, and K-FAC.
Comparing optimizer and decay regimes in practice
Switch through the five tabs below to compare each configuration’s update math, tuning failure mode, and measured evidence across CIFAR-10 and ImageNet32x32.
Select an optimizer configuration (or use Left and Right arrow keys) to compare its update rule, why naive tuning fails, and the paper's measured CIFAR-10 and ImageNet32x32 results.
Standard SGD with momentum and L2 penalty
Coupled baselineAdding (lambda'/2)||theta||^2 to the loss replicates weight decay only when lambda' = lambda / alpha, tying regularization strength directly to the learning rate.
- Why naive tuning breaks
- The top-10 hyperparameter basin lies along a diagonal in (alpha, lambda') space: changing learning rate alpha without inversely rescaling lambda' shifts effective weight shrinkage.
- Update mechanism
- Momentum buffer m_t accumulates eta_t * alpha * (grad f_t + lambda * theta_{t-1}), so any schedule multiplier eta_t or base alpha scales the penalty.
- CIFAR-10 100-epoch grid
- Strong Top-1 test error when alpha and lambda are co-tuned (e.g., alpha = 1/2 with lambda = 1/8 * 0.001), but brittle when swept one axis at a time.
- Practical takeaway
- Explains why standard SGD earned a reputation for finicky hyperparameter sensitivity even though L2 and decay are algebraically equivalent.
SGD with momentum and decoupled weight decay
Decoupled SGDSubtracting eta_t * lambda * theta_{t-1} directly in the parameter update separates decay from the gradient and momentum accumulator.
- Why naive tuning breaks
- Without decoupling, fixing a non-optimal learning rate traps L2 tuning away from the diagonal ridge; decoupling removes the alpha dependence.
- Update mechanism
- Algorithm 1 computes m_t from pure grad f_t and updates theta_t = theta_{t-1} - m_t - eta_t * lambda * theta_{t-1}.
- CIFAR-10 100-epoch grid
- Hyperparameter basin turns vertical around lambda = 1/4 * 0.001 to 1/2 * 0.001; even at alpha = 1/1024, optimizing lambda alone finds a good minimum.
- Practical takeaway
- Simplifies grid and random hyperparameter search in momentum SGD while matching or beating coupled L2 peak accuracy.
Standard Adam with L2 regularization
Broken adaptiveSumming lambda * theta into g_t forces the regularizer through Adam's second-moment denominator sqrt(v_hat_t) + epsilon, breaking equivalence with weight decay.
- Why naive tuning breaks
- Weights with large historic gradients accumulate large v_t, dividing down their L2 penalty; on CIFAR-10, nonzero L2 settings perform no better than lambda = 0.
- Update mechanism
- Proposition 2 proves no scalar L2 coefficient lambda' can match multiplicative weight decay when preconditioner M_t != kI.
- 1,800-epoch & external runs
- Trails AdamW at matched training loss on CIFAR-10 and ImageNet32x32, and gets only 61.34% accuracy on EEG ResNet (vs. 72.04% with AdamW).
- Practical takeaway
- Do not pass L2 loss penalties to Adam expecting uniform weight shrinkage; framework 'weight_decay' flags in pre-AdamW code often meant this broken behavior.
Adam with decoupled weight decay
Decoupled adaptiveAdaptive moments track only the batch loss gradient while weight decay shrinks every coordinate uniformly by eta_t * lambda outside the preconditioner.
- Why naive tuning breaks
- Keeping a fixed learning rate or unnormalized raw lambda across larger datasets still underperforms; cosine annealing and batch-budget normalization unlock full gains.
- Update mechanism
- Algorithm 2 subtracts eta_t * (alpha * m_hat_t / (sqrt(v_hat_t) + eps) + lambda * theta_{t-1}), equivalent under fixed diag(s)^(-1) to sqrt(s_i)-scaled L2 (Proposition 3).
- Measured evidence
- 15% relative reduction in test error vs. L2-Adam on both CIFAR-10 and ImageNet32x32 at alpha = 0.001, matching SGDW competitiveness and lowering test error at equal train loss.
- Practical takeaway
- Default choice for transformers and vision models alike: preserves Adam's fast early convergence while recovering SGD-grade generalization.
AdamW with normalized decay and warm restarts
Normalized restartsCombines cosine warm restarts (T_{i+1} = T_mult * T_i) with budget-normalized decay lambda = lambda_norm * sqrt(b / (B * T)) to get strong anytime accuracy.
- Why naive tuning breaks
- Reusing raw CIFAR-10 lambda on ImageNet32x32 (24x more batches per epoch) makes decay ~5x too strong without square-root budget normalization.
- Update mechanism
- Schedule multiplier eta_t = 0.5 + 0.5 cos(pi * T_cur / T_i) resets periodically while lambda scales inversely with sqrt(B * T / b).
- Measured evidence
- Reaches comparable final error to 1,800-epoch AdamW up to 10x faster at the first restart; lambda_norm = 0.025 and 0.05 transfer across CIFAR-10 and ImageNet32x32.
- Practical takeaway
- When scaling batch size, dataset size, or epoch budget, rescale weight decay rather than copying a raw lambda value verbatim.
Source: Loshchilov and Hutter (2019), Sections 2, 4, and Appendix B.
If you prefer the summary without clicking through the tabs, here is how all five regimes behave:
- SGD + L2: algebraically identical to weight decay only at
lambda' = lambda / alpha, leaving a diagonal tuning ridge whenever learning rate changes. - SGDW: subtracts
- eta_t * lambda * theta_{t-1}outside momentum, rotating the optimal basin vertical soalphaandlambdatune independently. - Adam + L2: feeds the weight penalty into
v_t, weakening shrinkage on high-gradient coordinates and yielding almost no improvement overlambda = 0on CIFAR-10. - AdamW: keeps decay outside
sqrt(v_hat_t), delivering a15%relative test-error cut over L2-Adam on CIFAR-10 and ImageNet32x32 plus lower test error at equal train loss. - AdamWR: adds cosine warm restarts and
lambda = lambda_norm * sqrt(b / (B * T))scaling, achieving up to10xfaster anytime accuracy and transferringlambda_normacross a24xdataset jump.
What AdamW does not fix for practitioners
Three caveats keep Loshchilov and Hutter’s findings properly scoped for modern training stacks.
First, the controlled ablations are vision-heavy. Section 5 explicitly notes that the systematic grids ran on CIFAR-10 and 32x32 ImageNet with Shake-Shake ResNets, calling for broader testing on tasks where regularization behaves differently (citing early GPT and EEG wins in Section 4.5 as external support rather than complete ablations). In single-epoch LLM pretraining today, decoupled weight decay still helps, though primarily for logit and activation norm control rather than preventing multi-epoch memorization.
Second, decoupling removes alpha-coupling inside one step, not schedule or budget coupling. In Algorithm 2, eta_t still multiplies both terms, and total shrinkage grows with update count; copying raw lambda from CIFAR-10 to ImageNet32x32 over-regularizes by roughly 5x without normalization. AdamW also keeps Adam’s 12-byte FP32 optimizer-state footprint per parameter (later partitioned by ZeRO optimizer sharding) and second-moment convergence limits.
Third, square-root normalization is an empirical heuristic, and parameter exclusions still matter. Appendix B.1 notes that sqrt(b / (B * T)) came from limited runs and better scaling laws likely exist. Production trainers also exclude biases and normalization gains from decay (unlike dropout, weight decay pulls every included weight toward zero) and monitor small-model training instability when pairing decay with warmup.
For engineers configuring an optimizer today, the rule is concrete: verify your library uses true decoupled AdamW, pair it with a learning rate schedule such as cosine decay, exclude 1D biases and normalization parameters from shrinkage, and rescale lambda whenever batch count or dataset size changes.


