Concept notebookChecking saved investigationReading browser-local route memory before showing a continuation.

Adam Optimizer

Adam is an adaptive optimizer that combines momentum (EMA of gradients) with per-parameter RMS normalization (EMA of squared gradients).

published · difficulty 3/5 · 16 min read

01

01

Intuition

Build the mental picture first so the rest of the page has something to attach to.

PredictName the object in plain language, then predict what should change.Leave with one reusable mental picture before notation appears.

Training is noisy: mini-batch gradients bounce around, and different parameters can have very different natural scales.

Adam combines two simple stabilizers:

  1. Momentum: smooth the gradient over time, so you don’t overreact to one noisy batch.
  2. RMS normalization: keep an exponential moving average of squared gradients so each parameter gets a step size that matches its typical gradient scale.

A useful mental model is: Adam maintains a per-parameter “velocity” (direction) and a per-parameter “uncertainty/scale” (how big gradients usually are), then divides one by the other.

Section prompt

Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.

02

02

Math

Translate the story into symbols, assumptions, and a derivation you can inspect.

InspectTrack the same object through the notation and check each symbol.Leave with the invariant the equations preserve.

Let gt=θLt(θt)g_t = \nabla_\theta \mathcal{L}_t(\theta_t)gt=θLt(θt) be the (stochastic) gradient at step ttt.

Adam keeps exponential moving averages:

mt=β1mt1+(1β1)gtm_t = \beta_1 m_{t-1} + (1-\beta_1) g_tmt=β1mt1+(1β1)gt
vt=β2vt1+(1β2)gt2v_t = \beta_2 v_{t-1} + (1-\beta_2) g_t^2vt=β2vt1+(1β2)gt2

Because mtm_tmt and vtv_tvt start at zero, Adam uses bias correction:

m^t=mt1β1t,v^t=vt1β2t\hat m_t = \frac{m_t}{1-\beta_1^t}, \qquad \hat v_t = \frac{v_t}{1-\beta_2^t}m^t=1β1tmt,v^t=1β2tvt

Update rule:

θt+1=θtαm^tv^t+ε.\theta_{t+1} = \theta_t - \alpha \frac{\hat m_t}{\sqrt{\hat v_t} + \varepsilon}.θt+1=θtαv^t+εm^t.

The division is elementwise, so Adam acts like a diagonal preconditioner: coordinates with consistently large gradients get smaller effective steps, while coordinates with consistently small gradients get larger relative steps. Bias correction matters most early in training because the moving averages are initialized at zero. The small ε\varepsilonε is not a learning signal; it prevents division by zero and can affect stability when gradients are tiny.

Typical defaults: β1=0.9\beta_1=0.9β1=0.9, β2=0.999\beta_2=0.999β2=0.999, ε=108\varepsilon=10^{-8}ε=108.

Section prompt

Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.

03

03

Code

Keep the implementation aligned with the notation so the algorithm is legible.

TraceMatch variables to symbols before reading the implementation.Leave with a runnable witness for the math.
import torch

alpha = 0.1
beta1, beta2 = 0.9, 0.999
eps = 1e-8

theta = torch.tensor([3.0], requires_grad=True)
m = torch.zeros_like(theta)
v = torch.zeros_like(theta)

for t in range(1, 51):
    loss = (theta ** 2).sum()
    loss.backward()

    g = theta.grad.detach()
    m = beta1 * m + (1 - beta1) * g
    v = beta2 * v + (1 - beta2) * (g * g)

    mhat = m / (1 - beta1 ** t)
    vhat = v / (1 - beta2 ** t)

    theta = (theta - alpha * mhat / (vhat.sqrt() + eps)).detach().requires_grad_(True)

    if t in [1, 5, 10, 50]:
        print(t, "theta=", theta.item(), "loss=", loss.item())
Section prompt

Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.

04

04

Interactive Demo

Use direct manipulation to connect the explanation to a moving system.

ManipulateChange one control and predict the visible response before reveal.Leave with the observed invariant or a repaired model.

Live Concept Demo

Explore Adam Optimizer

The stage is code-native and interactive. Use it to test the explanation against the mechanism.

difficulty 3/5undergraduatecode-aligned
Demo inquiry checkpoint

Manipulate one control and predict the visible change.

01Choose lensTrace a quantity
02ObserveDemo state pending
03GroundName the equation, invariant, or control that explains it.
04CarryNext: Weight Decay & AdamW: Decoupled Regularization

Choose what to inspect in Adam Optimizer. This shared fallback is an observation guide, not evidence of learning.

Loading interactive demo...

Use the demo to compare Adam to SGD variants and see how the moving averages change the effective step size.

Section prompt

Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.

4/4 sections ready

Concept: Adam Optimizer

What is the smallest example that makes Adam Optimizer click without losing the math?

BeforeDerivativesNow4/4 sections readyTryManipulate one control and predict the visible change.NextWeight Decay & AdamW: Decoupled Regularization
Object contextOptimization
ConceptLearner lens

Adam Optimizer

What is the smallest example that makes Adam Optimizer click without losing the math?

Mode questionCan I say the mechanism back in one sentence before I reveal anything?

Start with the prediction checkpoint, then compare the reveal to the mental model.

Take this move

Study modes

Keep the object fixed; change the lens.

Route back through the notebook

Carry the same object through intuition, math, code, and demo.

4/4 sections ready
Carry inDerivatives

Bring the mental model from Derivatives; this page will reuse it instead of restarting from zero.

Work hereAdam Optimizer

Adam is an adaptive optimizer that combines momentum (EMA of gradients) with per-parameter RMS normalization (EMA of squared gradients).

Carry outWeight Decay & AdamW: Decoupled Regularization

The next edge should feel earned: use the demo prediction here before following Weight Decay & AdamW: Decoupled Regularization.

After The First Pass

Turn the concept into an inspected object.

The lower panels are one second act: keep the object fixed, inspect it visually, check source boundaries, practice transfer, then attach the research question.
ConceptAdam OptimizerOptimization

Mechanism Storyboard

See the idea move before the page explains it

Adam is an adaptive optimizer that combines momentum (EMA of gradients) with per-parameter RMS normalization (EMA of squared gradients).

Demo notes open01 / Intuition
Editorial optimization illustration of adaptive Adam steps using momentum and second-moment scaling across a loss surface.
Prediction lens

Start with the picture, metaphor, or geometric mechanism.

Commit first

Before reading further, choose the kind of change Adam Optimizer should make visible.

Visual Inquiry

Make the image answer a mathematical question

Adam is an adaptive optimizer that combines momentum (EMA of gradients) with per-parameter RMS normalization (EMA of squared gradients).

4/4 stages readyDemo notes connected
Prediction

Which visible object should carry the first intuition?

Commit first

Pick the cue that should make Adam Optimizer easier to reason about before the page gives the answer.

Source Grounding

Canonical references for the mechanism on this page.

Object - ConceptAdam OptimizerQuestion

What is the smallest example that makes Adam Optimizer click without losing the math?

concept:optimization/adam
Boundary

sources: kingma-2014-adam

Check

Open the closest source note before trusting the local explanation.

Evidence

1 selected-object source shown first; 1 reference total.

Next move

Audit the claim boundary, then ask from the same selected object.

selected object source · paper · 2014Adam: A Method for Stochastic OptimizationKingma and Ba
Located CF editorial boundary

Grounds Adam's first- and second-moment estimates, bias correction, and adaptive step-size mechanics.

Used here as

Kingma and Ba's Algorithm 1 initializes m0 and v0 to zero, updates biased first-moment and second raw-moment estimates from gt and gt^2, computes bias-corrected estimates, and updates par...

Caveat

This checks Adam's original adaptive-moment update mechanics, not convergence guarantees, AdamW decoupled weight decay, AMSGrad, optimizer generalization debates, sparse-gradient variants...

Open source

Claim Review

Adam is an adaptive optimizer that combines momentum (EMA of gradients) with per-parameter RMS normalization (EMA of squared gradients).

Object - ConceptAdam OptimizerQuestion

What is the smallest example that makes Adam Optimizer click without losing the math?

concept:optimization/adam
Boundary

sources: kingma-2014-adam

Check

Treat every claim as provisional until source support and a local witness agree.

Evidence

1 structured claim check on this concept.

Next move

Run the prediction or practice transfer before asking for a grounded review.

1 CF editorial source-scope review recorded

Publisher-side editorial review is not independent replication. Claims without it still need exact source-support review. 1 reference and 3 local witnesses are available for inspection.

Adam maintains exponential moving averages of gradients and squared gradients, bias-corrects both from zero initialization, and takes elementwise adaptive steps by subtracting alpha*mhat_t/(sqrt(vhat_t)+epsilon).
Used here as

Kingma and Ba's Algorithm 1 initializes m0 and v0 to zero, updates biased first-moment and second raw-moment estimates from gt and gt^2, computes bias-corrected estimates, and updates parameters with alpha*m...

Local witness
Equation 1
mt=β1mt1+(1β1)gtm_t = \beta_1 m_{t-1} + (1-\beta_1) g_t
Equation 2
vt=β2vt1+(1β2)gt2v_t = \beta_2 v_{t-1} + (1-\beta_2) g_t^2
Caveat

This checks Adam's original adaptive-moment update mechanics, not convergence guarantees, AdamW decoupled weight decay, AMSGrad, optimizer generalization debates, sparse-gradient variants, or framework-speci...

Review stateCF editorial source-scope reviewClaim metadata: source checkedPublisher-side editorial review only; not independent replication. Check caveats and exact source scope.

Checked Kingma and Ba Algorithm 1 plus sections 2 and 3: the paper initializes m0 and v0 as zero vectors, updates biased first and second raw moment estimates from gt and gt^2, divides by 1-beta1^t and 1-beta2^t for bias correction, states vector operations are element-wise, and updates theta with alpha*mhat/(sqrt(vhat)+epsilon). Scope is original Adam update mechanics only.

Reviewer: codex+oracle; reviewed 2026-05-06

Practice notebook

Use the idea, then test it somewhere new

Adam is an adaptive optimizer that combines momentum (EMA of gradients) with per-parameter RMS normalization (EMA of squared gradients).

AttemptNo learning claim inferred
Object - ConceptAdam OptimizerQuestion

What is the smallest example that makes Adam Optimizer click without losing the math?

concept:optimization/adam
Boundary

sources: kingma-2014-adam

Check

Use one state from Adam Optimizer to explain what changes, why it changes, and which assumption the explanation needs.

Evidence

No learner move yet; no learning state is inferred.

Next move

Write first, use only the help you need, then try a new case without it.

Explain

Use one state from Adam Optimizer to explain what changes, why it changes, and which assumption the explanation needs.

Hint 1

Reveal when your model needs a nudge.

Hint 2

Reveal when your model needs a nudge.

Hint 3

Reveal when your model needs a nudge.

Grounded object roomClose
Selected object routeAsk from this object; carry one invariant back.sources: kingma-2014-adam
  1. ObjectConceptAdam Optimizer
  2. PredictBefore revealAdam Optimizer prediction
  3. WitnessCompare codeAdam Optimizer code witness 1
  4. RoomAsk groundedChecking local snapshot
ConceptAdam OptimizerOptimization
Code witness comparisonAdam Optimizer code witness 1alpha = 0.1Prediction before revealAdam Optimizer predictionManipulate one control and predict the visible change.
Grounded room questionWhat is the smallest example that makes Adam Optimizer click without losing the math?Checking local snapshot

Research Room

Attach the question to an exact object

Pick the concept, equation, source, code witness, claim, misconception, or demo state before asking for help. The handoff stays grounded to that object.
Next local actionNo local draft saved yet

Open the draft below to save one note and next action in this browser.

conceptOptimization

Adam Optimizer

Anchored question

What is the smallest example that makes Adam Optimizer click without losing the math?

Source boundaryInspect source ids: kingma-2014-adamStable content-object key attached
Role lenses for this object

These are fixed, deterministic perspectives derived from the selected object. They do not represent people, community contributions, or independent review.

Learner evidence requestAsk what would make "Adam Optimizer" feel predictable rather than familiar.
Assumption

Source ids kingma-2014-adam must support the exact object, not just the surrounding topic.

Source-checking summary

Treat this as a mechanism object: connect the definition to one equation, code witness, or demo before broadening the discussion.

Proposed experiment

Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo.

Next action

The learner can state the mechanism in their own words

Evidence4 checks
PredictionChecking carried observation
ActionReady for one action
AILearner handoff ready
Open source object
01PredictionChecking browser-local route memory
02EvidenceChecking for a carried observation
03BoundaryInspect source ids: kingma-2014-adam
04Next moveSave one next action
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
Local action draft

This draft stays locally in this browser for concept:optimization/adam.

No local draft saved.
Evidence to inspect
  • Source ids to inspect: kingma-2014-adam
  • Definition, prerequisite, and contrast concept links
  • The equation or code witness that makes the concept operational
  • One demo state that shows the invariant instead of a slogan
What would resolve this
  • The learner can state the mechanism in their own words
  • The learner can name the prerequisite that would repair confusion
  • The learner can predict how the mechanism changes under one perturbation
Object-attached AI handoff

I am working in Continuous Function's research reading room. Object: concept - Adam Optimizer Object key: concept:optimization/adam Context: Optimization Anchor id: concept/concept-notebook/optimization/adam Open question: What is the smallest example that makes Adam Optimizer click without losing the math? Evidence to inspect: - Source ids to inspect: kingma-2014-adam - Definition, prerequisite, and contrast concept links - The equation or code witness that makes the concept operational - One demo state that shows the invariant instead of a slogan Deterministic role lenses for this object: - Boundary: fixed perspectives, not people, community contributions, or independent review - Source-checking summary: Treat this as a mechanism object: connect the definition to one equation, code witness, or demo before broadening the discussion. - Proposed experiment: Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo. - Teach/transfer move: Turn the mechanism into one sentence that predicts a neighboring concept. - Assumptions: - Source ids kingma-2014-adam must support the exact object, not just the surrounding topic. - The stable content-object key lets local drafts, prompts, and route memory attach without changing the source page. - The concept explanation is local atlas prose until checked against its math, code, and source support. - Prerequisite gaps should become a repair route, not a reason to leave the object vague. - Role-lens requests: - Learner: ask for "Ask what would make "Adam Optimizer" feel predictable rather than familiar." | assumption: Source ids kingma-2014-adam must support the exact object, not just the surrounding topic. | next action: The learner can state the mechanism in their own words - Researcher: ask for "Source ids to inspect: kingma-2014-adam" | assumption: The stable content-object key lets local drafts, prompts, and route memory attach without changing the source page. | next action: The learner can name the prerequisite that would repair confusion - Experimenter: ask for "Choose one variable or condition to perturb before asking for an explanation." | assumption: The concept explanation is local atlas prose until checked against its math, code, and source support. | next action: The learner can predict how the mechanism changes under one perturbation - Professor: ask for "Find the smallest transferable rule a learner could reuse without the AI." | assumption: Prerequisite gaps should become a repair route, not a reason to leave the object vague. | next action: Teach or transfer: Turn the mechanism into one sentence that predicts a neighboring concept. What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action. Current deterministic role lens for this object: - Role lens: Learner - Evidence request: Ask what would make "Adam Optimizer" feel predictable rather than familiar. - Assumption to keep visible: Source ids kingma-2014-adam must support the exact object, not just the surrounding topic. - Proposed experiment: Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo. - Next action: The learner can state the mechanism in their own words

concept/concept-notebook/optimization/adam concept:optimization/adam