AdamW › The Effect of Gradient History on Regularization Strength
Language AI HandbookAll chapters AdamW › The Effect of Gradient History on Regularization StrengthOne section · Sections in this chapter8 / 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
Another way to understand the difference is to look at how the effective regularization strength varies across parameters with different gradient histories. This is the analytical picture underlying the numerical example from earlier.
# Simulate effective regularization strength across parameters
# with different gradient history magnitudes
np.random.seed(0)
# Imagine 1000 parameters with varying gradient history magnitudes
n_params = 1000
v_hat_values = np.logspace(-4, 0, n_params) # sqrt(v_hat) from 0.01 to 1.0
# For a given weight decay lambda
lam = 0.01
epsilon = 1e-8
# Adam+L2: regularization passes through adaptive scaling
# Effective regularization = lam / (sqrt(v_hat) + eps)
effective_reg_adam_l2 = lam / (np.sqrt(v_hat_values) + epsilon)
# AdamW: regularization is independent of v_hat
effective_reg_adamw = np.full(n_params, lam)
The plot makes the problem concrete. For parameters with small gradient histories (left side of the x-axis), Adam+L2 applies extremely strong effective regularization, up to 100 times stronger than for frequently-updated parameters (right side). AdamW's flat line demonstrates its key advantage: the regularization coefficient has a consistent, predictable meaning across all parameters. When you set weight_decay=0.01 in AdamW, every single parameter in the model is shrunk by a factor of at each step, no more and no less.