Skip to content
induwara.lk
Premium
induwara.lkAI · Optimization

Adam Optimizer Calculator — step-by-step update rule

Compute one or more steps of the Adam algorithm from a gradient and the standard hyperparameters. See the first and second moments, their bias-corrected values, the effective step size, and the new parameter — with a plain-SGD comparison. Free, no signup, everything runs in your browser.

By Induwara AshinsanaUpdated Jul 18, 2026
Adam update calculator

Hyperparameters

Examples
Decimals
First moment mₜ
0.020000
m̂ₜ (corrected) = 0.200000
Second moment vₜ
4.0000e-5
v̂ₜ (corrected) = 0.040000
Effective step size
0.001000
α·m̂ₜ / (√v̂ₜ + ε)
Updated parameter θₜ
0.499000
was 0.500000
Plain SGD would give
0.499800
θ − α·gₜ (step 0.000200)
Cross-check (efficient form)
✓ match
|θ − θ_efficient| = 0.0e+0

Step-by-step (t = 1)

  1. 1. mₜ = β1·0.000000 + (1−β1)·0.200000 = 0.020000
  2. 2. vₜ = β2·0.000000 + (1−β2)·0.200000² = 4.0000e-5
  3. 3. m̂ₜ = 0.020000 / (1−β11 = 0.100000) = 0.200000
  4. 4. v̂ₜ = 4.0000e-5 / (1−β21 = 0.001000) = 0.040000
  5. 5. θₜ = 0.500000 − α·0.200000/(√0.040000 + ε) = 0.499000

Method: mₜ = β1·mₜ₋₁ + (1−β1)·gₜ ; vₜ = β2·vₜ₋₁ + (1−β2)·gₜ² ; m̂ₜ = mₜ/(1−β1ᵗ) ; v̂ₜ = vₜ/(1−β2ᵗ) ; θₜ = θₜ₋₁ − α·m̂ₜ/(√v̂ₜ + ε). Source: Kingma & Ba, “Adam” (arXiv:1412.6980), Algorithm 1. Everything runs in your browser — no data leaves this page.

How it works

This tool implements the Adam optimizer exactly as defined in Kingma & Ba, “Adam: A Method for Stochastic Optimization” (ICLR 2015), Algorithm 1. Adam keeps two running averages per parameter — a first moment (the mean of recent gradients) and a second moment (the mean of recent squared gradients) — and uses them to give every parameter its own adaptive step size.

The state starts at m₀ = 0 and v₀ = 0. For each step t = 1, 2, … with gradient gₜ, five lines run in order:

  1. First moment. mₜ = β1·mₜ₋₁ + (1−β1)·gₜ — an exponential moving average of the gradient. With β1 = 0.9 it blends 90% of the old estimate with 10% of the new gradient.
  2. Second moment. vₜ = β2·vₜ₋₁ + (1−β2)·gₜ² — the same idea for the squared gradient, an estimate of its uncentred variance. β2 = 0.999 makes it change slowly.
  3. Bias correction. m̂ₜ = mₜ/(1−β1ᵗ) and v̂ₜ = vₜ/(1−β2ᵗ). Because m and v start at 0 they are biased toward 0 early on; dividing by 1 − βᵗ counteracts that. The factor is largest at t = 1 and tends to 1 as t grows.
  4. Parameter update. θₜ = θₜ₋₁ − α·m̂ₜ/(√v̂ₜ + ε). The direction comes from m̂ₜ, the per-parameter scaling from √v̂ₜ, and ε guards the division. At t = 1 with zero initial state this reduces to a step of about ±α regardless of the gradient magnitude.

The calculator mirrors the update ordering and defaults of PyTorch's torch.optim.Adam and Keras' tf.keras.optimizers.Adam (with ε = 1e-8, no weight decay, no AMSGrad). To keep the numbers trustworthy, every step is also computed with the paper's equivalent “efficient” reformulation — αₜ = α·√(1−β2ᵗ)/(1−β1ᵗ) applied to the raw moments — and the two results are compared on screen. They agree to floating-point precision. All computation is pure JavaScript in your browser; nothing is uploaded.

Worked examples

Example 1 — the first step (t = 1, g = 0.2)

  1. Defaults: α = 0.001, β1 = 0.9, β2 = 0.999, ε = 1e-8, m₀ = 0, v₀ = 0, θ₀ = 0.5
  2. m₁ = 0.9·0 + 0.1·0.2 = 0.02
  3. v₁ = 0.999·0 + 0.001·0.2² = 0.00004
  4. m̂₁ = 0.02 / (1 − 0.9¹) = 0.02 / 0.1 = 0.2
  5. v̂₁ = 0.00004 / (1 − 0.999¹) = 0.00004 / 0.001 = 0.04
  6. step = 0.001·0.2 / (√0.04 + 1e-8) = 0.001·0.2 / 0.2 = 0.001
  7. θ₁ = 0.5 − 0.001 = 0.499 (plain SGD would move only α·g = 0.0002 → 0.4998)

Example 2 — the second step (t = 2), carrying state forward

  1. Continue from Example 1: m₁ = 0.02, v₁ = 0.00004, θ₁ = 0.499, now g₂ = 0.1
  2. m₂ = 0.9·0.02 + 0.1·0.1 = 0.028
  3. v₂ = 0.999·0.00004 + 0.001·0.1² = 0.00004996
  4. m̂₂ = 0.028 / (1 − 0.9²) = 0.028 / 0.19 = 0.147368…
  5. v̂₂ = 0.00004996 / (1 − 0.999²) = 0.00004996 / 0.001999 = 0.024992…
  6. step = 0.001·0.147368 / (√0.024992 + 1e-8) = 0.000932…
  7. θ₂ = 0.499 − 0.000932 = 0.498068

Example 3 — very large gradient (edge case, t = 1, g = 1e9)

  1. Defaults, m₀ = 0, v₀ = 0, θ₀ = 0.5, gradient g = 1,000,000,000
  2. m₁ = 0.1·1e9 = 1e8 ; v₁ = 0.001·(1e9)² = 1e15 (no overflow — fits a double)
  3. m̂₁ = 1e8 / 0.1 = 1e9 ; v̂₁ = 1e15 / 0.001 = 1e18 ; √v̂₁ = 1e9
  4. step = 0.001·1e9 / (1e9 + 1e-8) ≈ 0.001
  5. θ₁ = 0.5 − 0.001 = 0.499 (the step is still ≈ α — Adam is scale-invariant on step 1)

Frequently asked questions

Sources & references

The formulas, defaults, and worked examples on this page were last cross-checked against the sources above on 2026-07-18. The tool models vanilla Adam for a single scalar parameter — no AdamW/weight decay, AMSGrad, or learning-rate schedules.

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want to suggest an improvement?

Email me at [email protected] — most fixes ship within 24 hours.