AdamW › AdamW vs. Adam: The Effect of Regularization Strength
Language AI HandbookAll chapters AdamW › AdamW vs. Adam: The Effect of Regularization StrengthOne section · Sections in this chapter10 / 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
The difference between Adam+L2 and AdamW is most visible when regularization matters most, specifically at larger regularization strengths and in models with heterogeneous gradient distributions. Let's run a systematic comparison across different weight decay values.
# Compare final weight norms for different regularization strengths
reg_values = [0.0, 0.001, 0.01, 0.05, 0.1, 0.2]
final_norms_adam = []
final_norms_adamw = []
for reg in reg_values:
_, norms_a, _ = train_with_norms(
adam_l2_update, lr=1e-2, reg=reg, seed=42, use_weight_decay=False
)
_, norms_w, _ = train_with_norms(
adamw_update, lr=1e-2, reg=reg, seed=42, use_weight_decay=True
)
final_norms_adam.append(norms_a[-1])
final_norms_adamw.append(norms_w[-1])
The plot reveals how Adam+L2 and AdamW respond differently to increasing regularization. AdamW shows more consistent and predictable weight decay behavior: as you increase the regularization coefficient, the final weight norm decreases correspondingly. Adam+L2 shows a weaker response to increasing regularization, particularly at higher values, because the adaptive scaling is partially counteracting the intended effect of the L2 penalty for parameters with large gradient histories.