Machine Learning & AI
Intermediate

Adam Optimizer

Adaptive optimizer combining momentum and per-parameter learning rates.

Formula

θ:=θ−α m^tv^t+ϵ\theta := \theta - \alpha\,\dfrac{\hat{m}_t}{\sqrt{\hat{v}_t}+\epsilon}

Variables

\hat{m}_tBias-corrected 1st moment
\hat{v}_t2nd moment
\epsilonSmall constant

Example

Default alpha=0.001 works for most nets

How it works

Adam updates parameters by taking a step in the direction suggested by the gradient, but it first smooths that gradient with momentum and then rescales the step using an estimate of how variable each parameter’s recent gradients have been. The first moment term ̂m_t captures the average direction, while the second moment term ̂v_t dampens updates where gradients have been large or noisy, so unstable dimensions do not dominate the learning process. The small ε prevents division by zero and keeps the update numerically stable.

When to use it

Use Adam when training neural networks or other differentiable models with noisy, sparse, or differently scaled gradients, especially if you want a robust default optimizer without manually tuning a separate learning rate for each parameter. It is commonly used for deep learning tasks such as image, text, and sequence models.

Worked example, step by step

Given: θ = 2.00, α = 0.01, \hat{m}_t = 0.20, \hat{v}_t = 0.04, ε = 0.000001 Step 1: Compute the denominator: \sqrt{\hat{v}_t} + ε = \sqrt{0.04} + 0.000001 = 0.2 + 0.000001 = 0.200001 Step 2: Compute the normalized step: \hat{m}_t / (\sqrt{\hat{v}_t} + ε) = 0.20 / 0.200001 \approx 0.999995 Step 3: Scale by the learning rate: α \times (...) = 0.01 \times 0.999995 \approx 0.00999995 Step 4: Update the parameter: θ := 2.00 - 0.00999995 = 1.99000005 Final answer: θ  becomes approximately 1.99.

Common mistakes to avoid

  • Forgetting that \hat{m}_t and \hat{v}_t are bias-corrected, especially early in training
  • Using \hat{v}_t without the square root, which changes the scale of the update
  • Choosing an ε that is too large and unintentionally dominating the denominator

Did You Know?

Adam (2015) is the default optimizer for most deep-learning models today.

Share this formula

Reviewed & maintained by the FormulaWon editorial teamLast reviewed September 2026