Skip to content

Adam Optimizer First Step Worked by Hand

2026-11-14

Adam's first update moves each parameter by about the learning rate, for any gradient much larger than ε, once its moving averages are bias-corrected. Kingma and Ba correct them because the first moment m and the second moment v start at zero, so early values are biased toward zero; Adam divides them by 1 − βᵗ.

Algorithm 1 in the paper does five things per step: g = the gradient; m ← β₁m + (1 − β₁)g; v ← β₂v + (1 − β₂)g²; m̂ = m / (1 − β₁ᵗ) and v̂ = v / (1 − β₂ᵗ); then θ ← θ − α · m̂ / (√v̂ + ε). The paper's good defaults are α = 0.001, β₁ = 0.9, β₂ = 0.999 and ε = 10⁻⁸.

Try it by hand. At step 1 take a gradient g = 2. Then m = 0.1 · 2 = 0.2 and v = 0.001 · 4 = 0.004. Without correction the step would be 0.001 · 0.2 / √0.004 = 0.00316, more than three times α. With it, m̂ = 0.2 / 0.1 = 2 and v̂ = 0.004 / 0.001 = 4, so the step is 0.001 · 2 / (2 + 10⁻⁸), which is 0.001 to eight decimal places.

Now take g = 200. Then m = 20 and v = 40, so m̂ = 200 and v̂ = 40,000, √v̂ = 200. The step is again 0.001. The update is a ratio of the gradient to its own size, which is why the paper, assuming ε = 0 in that section, says the effective step is "approximately bounded by the stepsize setting α" and calls this a trust region. The qualifier in the first sentence matters: the corrected first step is α · |g| / (|g| + ε), so a gradient near ε = 10⁻⁸ would step well below α.

Kingma and Ba, ICLR 2015, Algorithm 1, §2.1 and §3