Adam (adaptive moment estimation) maintains exponential moving averages of the first moment mt and the second moment (uncentered variance) vt of the gradient, with bias correction: mt=β1mt−1+(1−β1)gt, vt=β2vt−1+(1−β2)gt2; bias correction m^t=1−β1tmt, v^t=1−β2tvt (the geometric series gives E[mt]=(1−β1t)E[g]; for small t the moments are systematically underestimated, and dividing by 1−β1t fixes this); parameter update θt+1=θt−ηv^t+ϵm^t. Defaults: β1=0.9, β2=0.999, ϵ=10−8, base LR η=10−3. The ratio m^t/v^t has magnitude ~1, i.e. per-parameter normalization by gradient RMS: large-gradient directions are scaled down, small ones up, making Adam robust to sparse gradients and ill-conditioning (large κ). ϵ belongs in the denominator: numerical stability (avoid division by zero when v^t≈0 early in training) and an implicit step bound η/ϵ. AdamW decouples weight decay from L2: θt+1=θt−η(λθt+v^t+ϵm^t), giving every parameter a constant per-step decay factor 1−ηλ.
💡Use Cases
the default optimizer for Transformers, BERT/GPT and other large models; the first choice for large batches, sparse features and multimodal workloads; interviews always ask to write the four formulas, explain bias correction, quote the default βs, and contrast AdamW with Adam+L2.
⚡Key Problems Solved
SGD+momentum shares one learning rate across all parameters, which cannot fit ill-conditioned or sparse gradients; Adam adaptively scales the per-parameter step and bias correction prevents early iterations from being slowed by underestimated moments. AdamW fixes Adam+L2: the L2 term λwt enters gt and is rescaled by v^t, so the effective decay ηλwt/v^t varies with gradient magnitude — large-gradient directions are regularized too much, small ones too little; decoupling yields a constant decay rate per parameter, training more stably and generalizing better.
🎯5 High-Frequency Exam Points
1
Write Adam's four formulas (moment recursions, bias correction, parameter update) and quote the defaults β1=0.9, β2=0.999, ϵ=10−8, η=10−3.
2
Why is bias correction needed? Sum the geometric series to prove E[mt]=(1−β1t)E[g], explain why the bias is worst at t=1 (1−β1=0.1), and why dividing by 1−β1t gives E[m^t]=E[g].
3
Why update by m^t/v^t? Relation to RMSProp/AdaGrad; why must ϵ sit in the denominator (numerical stability + step bound η/ϵ)?
4
Adam vs SGD+momentum: use cases and generalization differences (why SGD often wins on CV while large models standardize on Adam); why Adam converges fast early but can be unstable later.
5
Write the AdamW update and compare with Adam+L2: how does dividing the L2 term by v^t distort the effective regularization? Why does decoupling give a constant per-step decay 1−ηλ?