Adam = exponential moving averages of the first moment mt and second moment vt, plus bias correction. With gradient gt: mt=β1mt−1+(1−β1)gt, vt=β2vt−1+(1−β2)gt2. Expanding mt as a geometric series: mt=(1−β1)∑i=1tβ1t−igi, so older gradients get weight β1t−i, decaying exponentially. Bias derivation: assuming stationary gradients E[gi]=E[g], we get E[mt]=(1−β1)E[g]∑k=0t−1β1k=(1−β1)E[g]⋅1−β11−β1t=(1−β1t)E[g]. For small t this factor is far below 1 (at t=1 it is 1−β1=0.1), so early moments are systematically underestimated; dividing by 1−β1t gives m^t=1−β1tmt and v^t=1−β2tvt (since E[vt]=(1−β2t)E[g2]), so E[m^t]=E[g]. Full update: wt+1=wt−ηv^t+ϵm^t.
💡Use Cases
the default optimizer for Transformers, diffusion models and other large-batch / sparse-gradient workloads; interviews frequently ask why bias correction is needed and how AdamW differs from Adam with L2.
⚡Key Problems Solved
vs SGD+momentum, Adam adaptively scales the per-parameter step by m^t/v^t (scale ~1), which is robust to ill-conditioning (κ large) and sparse gradients, while bias correction prevents slow early steps from underestimated moments. AdamW decouples weight decay from L2: in Adam+L2 the term λwt enters gt and gets rescaled by v^t, so the effective decay ηλwt/v^t varies with historical gradient magnitude — large-gradient directions are regularized too much, small ones too little; AdamW applies wt+1=wt−η(λwt+v^t+ϵm^t), giving every parameter a constant per-step decay factor 1−ηλ, which trains more stably and generalizes better.
🎯5 High-Frequency Exam Points
1
Write Adam's moment recursions, expand mt=(1−β1)∑i=1tβ1t−igi and explain how historical weights decay.
2
Prove the bias: sum the geometric series to show E[mt]=(1−β1t)E[g] and explain why the bias is worst at t=1 (1−β1=0.1).
3
Why divide by 1−β1t? Prove E[m^t]=E[g] after correction; why must the second moment v^t be corrected and square-rooted?
4
Compare Adam+L2 vs AdamW: how does dividing λwt by v^t distort the effective regularization, and what does decoupling fix?
5
Write the full update wt+1=wt−ηv^t+ϵm^t; why does ϵ belong in the denominator rather than the numerator?