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-layer 2x96d Shake-Shake ResNet, 1,800 epochs) and ImageNet32x32.
  • Formal inequivalence (Proposition 2): for any optimizer with a non-scalar preconditioner M_t != kI, no L2 loss penalty (lambda' / 2) ||theta||^2 can reproduce multiplicative weight decay (1 - lambda) theta_t.
  • Scale-adjusted penalty (Proposition 3): under a fixed diagonal preconditioner diag(s)^(-1), true weight decay matches minimizing f_t(theta) + (lambda' / 2) ||theta * sqrt(s)||^2, regularizing parameters with large historical gradient scale s_i more strongly by sqrt(s_i) than plain L2 does.
  • Up to 10x faster anytime accuracy with warm restarts: pairing AdamW with 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 from 61.34% (Adam) to 72.04% (AdamW).
Where the penalty enters: L2-regularized Adam vs. decoupled AdamW
Adam with L2 penalty
Regularizer gradient is mixed into g_t before adaptive scaling.
1. Sum gradients: g_t = grad f_t + lambda theta
Both task gradient and weight penalty update first moment m_t and second moment v_t.
2. Preconditioner distorts decay: g_t / (sqrt(v_hat_t) + eps)
Weights with large historic gradients have large v_hat_t, shrinking their effective regularization.
AdamW (decoupled)
Adaptive moments track only the data loss; decay acts directly on weights.
1. Pure loss gradient: g_t = grad f_t(theta)
Moments m_t and v_t adapt strictly to minibatch loss curvature without L2 interference.
2. Uniform direct shrink: - eta_t lambda theta
Subtracted outside sqrt(v_hat_t) so every parameter decays at the same scheduled rate eta_t lambda.

Update equations from Loshchilov and Hutter (2019), Section 2 and Algorithm 2.

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.

How three optimizer setups treat regularization and learning rate
SGD with L2 (lambda’)

Equivalent to weight decay only at lambda’ = lambda / alpha; tuning alpha forces retuning lambda’ along a diagonal ridge.

Adam with L2 (lambda)

Penalty passes through sqrt(v_hat_t); high-gradient weights under-decay, and best L2 runs match lambda = 0 on CIFAR-10.

AdamW (decoupled)

Scales only grad f_t; every weight decays by eta_t lambda, opening a broad vertical hyperparameter valley.

Comparison from Loshchilov and Hutter (2019), Sections 2 and 4.2.

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.

Five regularization regimes compared across SGD and Adam

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 baseline

Adding (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.

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 so alpha and lambda tune independently.
  • Adam + L2: feeds the weight penalty into v_t, weakening shrinkage on high-gradient coordinates and yielding almost no improvement over lambda = 0 on CIFAR-10.
  • AdamW: keeps decay outside sqrt(v_hat_t), delivering a 15% 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 to 10x faster anytime accuracy and transferring lambda_norm across a 24x dataset 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.