Dissection · Kingma & Ba, 2015
Anatomy of Adam
Kingma and Ba's optimiser, dissected: every line of Algorithm 1 drawn as real blocks on a 151-parameter network, checked against PyTorch, with a research desk that reruns Reddi et al.'s counterexample, finds how rare a large gradient must be to defeat it, and tests the paper's claims about bias correction, the size of the step and ε.
PaperKingma & Ba, ICLR 2015
Model151 parameters, live
Reading35 min · 25 steps
Published2026-10-18
01Overview
An optimiser, drawn as the machine it is
In December 2014 Kingma and Ba proposed "an algorithm for first-order gradient-based optimization of stochastic objective functions, based on adaptive estimates of lower-order moments" [1]. It is named for those moments: "the name Adam is derived from adaptive moment estimation." It became the default optimiser of much of deep learning, and the base of AdamW.
What you are looking at is Algorithm 1 of the paper, run on a small network. The network has 151 parameters (a 2-10-10-1 network that separates two interleaved spirals), laid out as three bands of cells: the first layer, the second layer and the output weights. Each line of the algorithm is one station of three such bands, from the gradient at the bottom, through the two moving averages on the left and right, to the step at the top. A cell sits at the same place in every station, so one cell, followed up the page, is one parameter's whole story: its gradient, its two averages, their corrected versions, and the step it takes.
The page is showing step of a training run, with . Type another step into the bar above, or add settings such as 20 b2=0.98, and every block is recomputed by the same code that the tests check against PyTorch. The visual grammar, tensors as blocks of cells, follows Brendan Bycroft's LLM Visualization [2].
How to use this pageScroll the article, or use ← →. Drag the stage to orbit, right-drag to pan, scroll on it to zoom; O shows the whole machine, C returns to the step's view, R replays its animation. Hover any cell for its value and the arithmetic behind it. The step number takes t, a= (α), b1=, b2=, eps= and bc=0 (bias correction off).
Go deeper: Optimisers: SGD, Adam, AdamW, Lion
02Overview
Five promises in one paragraph
The introduction lists what the method offers: "the magnitudes of parameter updates are invariant to rescaling of the gradient, its stepsizes are approximately bounded by the stepsize hyperparameter, it does not require a stationary objective, it works with sparse gradients, and it naturally performs a form of step size annealing." It was "designed to combine the advantages" of AdaGrad [3], which suits sparse gradients, and RMSProp [4], which suits on-line and non-stationary settings. And it came with a theorem: "We show Adam has O(√T) regret bound".
This article takes the promises one at a time and checks them. The invariance and the bound on the step are tested on the stage (steps 12 and 13). The regret theorem, whose proof was later found to be wrong, and the sparse-gradient claim are the subject of the research desk at the end, together with the paper's bias-correction experiment redone at miniature scale and two claims it made in passing: that the step stays within α, and what happens when ε dominates.
The settings are the paper's good defaults: α = 0.001, β₁ = 0.9, β₂ = 0.999, ε = 10⁻⁸, with one change here: the miniature uses α = 0.01 because its training run is short.
Go deeper: Optimisation theory · Hyperparameter search hygiene
03Baseline
What plain gradient descent does with these gradients
Before the machinery, the baseline. Stochastic gradient descent moves every parameter against its gradient, by the same multiple of it:
θt=θt−1−αgt
The block beside the gradient on the stage is that step for α = 0.1, drawn on the same colour scale as Adam's step further up. Look at its pattern: a few cells are tall and most are nearly flat. Across the 151 parameters at this step the gradient's size varies by a factor of between its 10th and 90th percentiles, and by between the smallest and the largest. A single α cannot suit both ends: raise it until the small ones move and the large ones overshoot; lower it until the large ones are safe and the small ones stand still.
This is the problem the adaptive methods address, and it is why the paper's first claim is about scale. If the step is a ratio of the gradient to its own recent size, it no longer depends on the units in which the gradient is measured. The gradient itself comes from backpropagation, dissected in the earlier piece on that algorithm.
Go deeper: Calculus and gradients · Backpropagation and automatic differentiation
04Algorithm 1
Where the gradient comes from: twenty points and a loss
The algorithm is stated for "random subsamples (minibatches) of datapoints": at step t it sees a loss ft computed on part of the data. Here the 200 points are shuffled afresh every epoch and cut into minibatches of 20, so ten steps make an epoch. The blocks at the bottom of the stage are the minibatch of this step: its twenty points x (labelled by their index in the data), the two tanh layers, and the output probability p beside the error p−y.
ft(θ)=201n∈Bt∑[log(1+ezn)−ynzn]
Here zn is the network's output (a logit) for point n and yn its class. On this minibatch the loss is . Over all 200 points the network at the start of this step has a loss of ; a loss near 0.69 is chance, so a network that is still there has not yet found the spirals.
The loss on one minibatch is a noisy stand-in for the loss on everything. That noise is what the second moment will measure.
Go deeper: Cross-entropy loss
05Algorithm 1
The gradient is a noisy estimate of the one you want
Line 4 of Algorithm 1 is gt←∇θft(θt−1): the gradient of the minibatch loss at the parameters the previous step left. The stage draws it as three bands, one cell per parameter, blue where the loss would fall if the parameter increased and amber where it would rise.
It is an estimate. The gradient of the loss over all 200 points, which no step ever sees, points a little elsewhere: the cosine between the two at this step is . The tall cells are where the signal is strong, the flat ones where it is weak, and from step to step each cell flips and wanders. Two statistics of that wandering are what Adam keeps for every parameter, "estimates of the 1st moment (the mean) and the 2nd raw moment (the uncentered variance) of the gradient."
The largest gradient at this step: .
Go deeper: Estimators, bias, variance and consistency
06Algorithm 1
m: an average of recent gradients
The first moment is an exponential moving average of the gradient. Each step keeps a fraction β1 of the old average and adds a fraction 1−β1 of the new gradient:
mt=β1mt−1+(1−β1)gt=(1−β1)i=1∑tβ1t−igi
The right-hand form says what it is: a weighted sum of every gradient so far, with weights that fall by a factor β1 per step of age. With β1=0.9 a gradient's weight falls to about a third every ten steps, so m is a mean over roughly the last ten minibatches. That averages away much of the minibatch noise; it is what momentum does.
It is momentum in the usual sense. PyTorch's SGD with momentum μ keeps buf = μ·buf + g [5], which is mt/(1−β1) with β1=μ: the same weights, scaled so that a steady gradient g builds up to g/(1−μ). test.mjs checks that limit.
On the stage, the white cell is the largest gradient; follow it from the block on the left (mt−1), through the gradient, to the block above it (mt).
Go deeper: Exponential smoothing · Optimisers: SGD, Adam, AdamW, Lion
07Algorithm 1
v: how large the gradients have been, coordinate by coordinate
The second moment is the same average applied to the square of each gradient, element by element:
vt=β2vt−1+(1−β2)gt2
Its square root is the typical size of that parameter's gradient, whether positive or negative, over roughly the last 1/(1−β2) steps: a thousand steps at the default β2=0.999. The stage draws v, in the same units as g, as bars. The Transformer, whose original recipe is the most cited use of Adam, set β₁ = 0.9, β₂ = 0.98 and ε = 10⁻⁹ [6], a memory of only fifty steps.
The paper notes that v^t "is an approximation to the diagonal of the Fisher information matrix", so Adam's division by v is a cheap, diagonal relative of natural-gradient preconditioning, with the square root making it more conservative than the full thing.
Follow the white cell: . At the first step vt−1 is zero, and with the default β2=0.999 the new vt is a thousandth of the squared gradient, which is the problem of the next step.
Go deeper: Optimisation theory
08Algorithm 1
Starting from zero leaves the averages short
Both averages start at zero, and a zero is not a gradient. After one step, with the defaults, m is a tenth of the gradient and v a thousandth of its square. The paper says so: "these moving averages are initialized as (vectors of) 0's, leading to moment estimates that are biased towards zero, especially during the initial timesteps, and especially when the decay rates are small (i.e. the βs are close to 1)." The remedy follows from writing vt as a sum over the gradients seen and taking expectations:
E[vt]=E[gt2](1−β2t)+ζ
where ζ=0 if the true second moment does not change. The factor 1−β2t is the total weight of the t gradients seen; the rest of the weight is on the initial zero. "In algorithm 1 we therefore divide by this term to correct the initialization bias."
The two strips on the stage show the factors for this run's β1 and β2, for steps from 1 to 5,000 on a log axis, with your step marked. At step they are and . Without correction, the first step would be (1−β1)/1−β2 times α: for these settings times.
Go deeper: Estimators, bias, variance and consistency
09Algorithm 1
Dividing by what is missing
The corrected averages divide each by the weight it has actually accumulated:
m^t=1−β1tmt,v^t=1−β2tvt
At this step . Hover the white cell on either block to see its arithmetic. The correction is exact in the one case it was designed for: if every gradient is the same number g, then m^t=g and v^t=g2 at every t, however small t is. test.mjs checks that identity for four settings of (β1,β2) over fifty steps.
The correction fades. After a few multiples of 1/(1−β) steps the factor is within a few per cent of 1 and the corrected and uncorrected averages agree: the second factor needs about three thousand steps at β2=0.999, and about 150 at 0.98. Type 20 bc=0 in the bar above to switch the correction off and see the stage without it.
Go deeper: Numerical computation gotchas
10Algorithm 1
The step is a ratio, so its size does not depend on the gradient's
The last line of the loop divides one corrected average by the square root of the other:
θt=θt−1−αv^t+ϵm^t
The numerator is the direction and strength of the recent gradient; the denominator is its recent size. Their ratio is a number near ±1 when the gradient has been steady and near 0 when it has been mostly noise. The constant ε keeps the division finite where v^ is zero.
Look at the two callouts on the step block: . What sets the size of a step is not the size of the gradient but how consistently it has pointed one way. A coordinate whose gradient keeps its sign has ∣m^∣≈v^ and moves by about α; one whose gradient flips from step to step averages to a small m^ and moves little, however large the individual gradients are. At step 1 there is no history and every cell moves by exactly α. Across all 151 cells at this step, moved by at most α, the median step is α and the largest is α. The next two steps put numbers on that.
The paper also gives a cheaper ordering of the same arithmetic: fold the two corrections into the step size, αt=α1−β2t/(1−β1t), and update with mt/(vt+ϵ^).
Go deeper: Optimisers: SGD, Adam, AdamW, Lion
11Algorithm 1
Subtract the step
The parameters move by Δt, and the loop starts again. The stage shows the parameters before, the step, and the parameters after; the white cell is the largest gradient's parameter, . Adam keeps three numbers for each parameter, θ, m and v: for these 151 parameters that is 453 numbers, which is the paper's "little memory requirements".
One step on this minibatch changes the loss on all 200 points from to : it . A single stochastic step need not lower the full-data loss, and early on it hardly moves it; what matters is the direction of many steps, and the speed at which the step falls from its early size to the small, noisy size of late training, which the research desk measures (E3).
Go deeper: Learning-rate schedules
12Why the step looks like that
Is the step bounded by α?
Section 2.1 argues that the step has a size the user controls. With ε = 0 the step is Δt=αm^t/v^t, and the paper states two bounds: "|Δt| ≤ α · (1 − β1)/√(1 − β2) in the case (1 − β1) > √(1 − β2), and |Δt| ≤ α otherwise." The first case "only happens in the most severe case of sparsity: when a gradient has been zero at all timesteps except at the current timestep." It argues that in more common cases the ratio is close to ±1, so that ∣Δt∣≲α, which "can be understood as establishing a trust region around the current parameter value". The ratio is called the signal-to-noise ratio, and "the SNR value typically becomes closer to 0 towards an optimum, leading to smaller effective steps".
The stage highlights, in white, any cell whose step exceeds α. At this step are within α; the largest is α, on the .
Go deeper: Gradient clipping · Loss spikes and divergence
13Why the step looks like that
Multiply every gradient by c and nothing changes
The abstract claims that the method "is invariant to diagonal rescaling of the gradients", and section 2.1 gives the one-line reason: "The effective stepsize ∆t is also invariant to the scale of the gradients". Scaling the gradients by c scales m^ by c and v^ by c2, so
c2v^tcm^t=v^tm^t
The same holds for any diagonal rescaling, a different ci for each coordinate, because every operation in the loop is element-wise. On the stage, the gradient block swells to a thousand times its size and back while the step below it does not move. It is computed, not drawn: the engine reruns the whole history with the loss multiplied by 1,000 and by 0.001, and at this step the largest difference between the steps, with ε = 0, is α.
The invariance is exact only for ε = 0. With ε = 10−8, a gradient so small that v^ is comparable to ε is no longer divided by its own size, and the step shrinks. The figure shows it live: over 300 steps the invariance is intact down to a loss scale of about 10−4, visibly broken by 10−5, and gone by 10−6 (research E4 measures where, and why).
Go deeper: Mixed-precision training · Numerical computation gotchas
14Theory
A convergence proof, and the quantity it needed
Section 4 analyses Adam in the online learning framework of Zinkevich [7]: "Since the nature of the sequence is unknown in advance, we evaluate our algorithm using the regret":
R(T)=t=1∑T[ft(θt)−ft(θ∗)]
the loss paid along the way, minus the loss of the best fixed point in hindsight. The theorem bounds it by a multiple of T, comparable to the best known bound for this general convex online learning problem, so the average regret R(T)/T tends to zero (Corollary 4.2). Two details of the statement matter. It is proved "when the learning rate αt is decaying at a rate of t^−1/2 and first moment running average coefficient β1,t decay exponentially", not for the constant settings of Algorithm 1; and only for convex losses, where the paper says outright that "our convergence analysis does not apply to non-convex problems".
In 2018 Reddi, Kale and Kumar showed that the proof "erroneously assumes that Γ_t is positive semi-definite and is hence, incorrect" [8]. Γt is the change in the inverse learning rate:
Γt+1=αt+1vt+1−αtvt
The proof telescopes a sum of such terms and needs each to be non-negative: "This quantity essentially measures the change in the inverse of learning rate of the adaptive method with respect to time." For SGD and AdaGrad the inverse learning rate never falls. For Adam it does, whenever a large gradient ages out of the moving average. The stage shows Γt for Reddi et al.'s own counterexample (C=3): blue cells in the Adam row are steps where Adam's learning rate rises; the AMSGrad row, which keeps a running maximum of v, has none. The rows above are the gradients and the iterates, which the research desk will examine.
Go deeper: Online learning and regret bounds
15Related work
Adam's family, on one surface
Section 5 places Adam among its relatives, and two of its statements can be run. First, AdaGrad: "AdaGrad corresponds to a version of Adam with β1 = 0, infinitesimal (1 − β2) and a replacement of α by an annealed version αt = α · t^−1/2". That is because as β2→1 the corrected second moment tends to the plain average of squares, v^t→t−1∑igi2. test.mjs runs Adam with β1=0, 1−β2=2−30 and α/t beside AdaGrad on the same gradients: with the correction they agree to 10−10 in the parameters; without it, as the paper says, "the direct correspondence … does not hold", and after 200 steps the parameters are thousands apart.
Second, RMSProp. The paper separates it from Adam: "RMSProp with momentum generates its parameter updates using a momentum on the rescaled gradient, whereas Adam updates are directly estimated using a running average of first and second moment of the gradient." The paper adds that RMSProp lacks a bias-correction term, which matters most when β₂ is close to 1, and PyTorch's RMSprop does the momentum as described, with buf = μ·buf + g/(√v + ε) [5]. Both the AdaGrad and RMSProp algorithms are taken from the Adam paper's account of them; the lecture that introduced RMSProp [4] and AdaGrad's own paper [3] were not read for this page.
On the stage is Beale's function, a long curved valley with a flat shelf in front of it, and the paths of five optimisers from (−2, −2). The step sizes were chosen once, not tuned, so the picture shows how each moves and is not a ranking. After 1,500 steps their values of the function are: (the minimum is 0, at (3, 0.5)). The figure lets you move the start; from some starts an optimiser ends on a flat shelf near (−1.5, 1.4) or leaves the plotted square, which is where the step-size choice shows.
Go deeper: Optimisers: SGD, Adam, AdamW, Lion
16Extensions
Take the norm to infinity
Adam divides by an L2-style size of recent gradients. Section 7.1 generalises to Lp and lets p→∞, where "conveniently enough, we don't need to correct for initialization bias". The infinity norm of the decayed history is a maximum:
ut=max(β2ut−1, ∣gt∣)=max(β2t−1∣g1∣, …, β2∣gt−1∣, ∣gt∣),Δt=1−β1tαutmt
The step is bounded exactly: "|∆t| ≤ α", with defaults α = 0.002, β₁ = 0.9, β₂ = 0.999. test.mjs checks the unrolled form against the recursion for forty steps, that the Lp norm approaches the maximum as p grows, and the bound over two hundred random gradients with an occasional large one.
The stage shows AdaMax's u and the step AdaMax would take, computed from the same gradients as the Adam blocks beside them, so the two denominators can be compared cell by cell. At this step, with the white cell's u = against Adam's v^ = : .
17Extensions
Average the iterates, and correct that too
Section 7.2 adds a second use of the same idea. The last iterate is noisy, so "an exponential moving average over the parameters can be used, giving higher weight to more recent parameter values." It takes one line, and it starts from zero like the other averages, so it needs the same correction:
θˉt=β2θˉt−1+(1−β2)θt,θ^t=1−β2tθˉt
The paper writes the averaging decay as β2; nothing requires it to equal the decay of v. The block on the right of the stage is θ^t for this run; the root-mean-square difference between it and the current parameters is . test.mjs checks the corrected average against its closed form as a weighted sum of all the iterates.
18Afterlife
What later work did to Adam
Most of what has happened to Adam since 2015 is a reaction to one of the claims above.
- The proof. Reddi et al. showed that its convergence claim fails and proposed AMSGrad, which maintains the maximum of all v_t until the present time step, with a regret guarantee [8]. Défossez et al. then proved that Adam itself converges at the rate of AdaGrad when β₂ goes to 1 and α to 0, and noted that the counterexamples use a small exponential decay parameter β₂ < 1/5 [9]. Zhang et al. gave the reason: Reddi et al. pick the problem after picking the hyperparameters, while practical applications often fix the problem first and then tune them [10]. Research E1b asks how large "large enough" β₂ is.
- Weight decay. Adding an L2 penalty to the loss and decaying the weights are the same for SGD but not for adaptive gradient algorithms, such as Adam, so AdamW decouples them [11].
- Warm-up. Adam is usually run with a learning-rate warm-up. The Transformer recipe used 4,000 warm-up steps with β2=0.98 [6]. Liu et al. argue the cause is that the adaptive learning rate's variance is problematically large in the early stage, which the bias correction does not remove [12].
- Generalisation. Wilson et al. found that solutions found by adaptive methods generalize worse than SGD, even when these solutions have better training performance [13]. Choi et al. showed that the comparison depends on the tuning protocol: as tuning effort grows without bound, more general optimizers should never underperform the ones they can approximate, and they found that the popular adaptive gradient methods never underperform momentum or gradient descent when the search space is large enough [14].
The first of these is tested on the research desk below; the second to fourth are cited here and not tested, because they are about scales and objectives this page's miniature cannot reach.
Go deeper: Weight decay in pretraining · Warm-up and why it helps · Learning-rate schedules · The Transformer · Multi-seed reporting
19Experiments
What the paper tried, and what fits on this page
Section 6 compares Adam with SGD with Nesterov momentum, AdaGrad, RMSProp, AdaDelta and the sum-of-functions optimiser on L2-regularised multi-class logistic regression on MNIST, on a text classification problem with sparse features, on a network with two hidden layers of 1000 ReLU units, on a convolutional network with three conv-and-pool stages and a layer of 1000 ReLUs, and, for the bias-correction test, on a variational auto-encoder [15]. Its conclusion: "Overall, we found Adam to be robust and well-suited to a wide range of non-convex optimization problems in the field machine learning."
None of those models can run in a browser tab, and the comparisons depend on how the settings were chosen: "searched over a dense grid and the results are reported using the best hyper-parameter setting." This page does the part that fits. The figure below trains the 151-parameter network with any of seven optimisers at any step size; try SGD at its best step size against Adam at its best, and Adam at α = 0.1 against 0.001. The research desk then reports every cell of a grid, not the best.
Go deeper: Hyperparameter search hygiene · Multi-seed reporting and run-to-run variance
20Research desk
Reproducing the counterexample, and the paper's own experiment
The research desk tests claims the 2015 paper made, or that its critics made about it. Hypotheses and verdict rules were written down before any of the runs, in research/README.md, and committed before they ran; the result paragraphs on this page are generated from the result files by the same rules, so they cannot be edited to fit. Every run uses this page's engine, which test.mjs checks against PyTorch's optimisers. The first question is whether Reddi et al.'s counterexample does what it says.
Claim"There is an online convex optimization problem where Adam has non-zero average regret": a sequence of linear functions on the interval from −1 to 1, Cx at every third step and −x at the others with C>2, and β₁ = 0 and β₂ = 1/(1 + C²). The mean gradient is (C−2)/3>0, so x=−1 is optimal. "The large gradient C is unable to counteract this effect since it is scaled down by a factor of almost C for the given value of β2."
Hypothesis(i) for every C from 2.5 to 100, Adam's iterate stays above 0, is exactly at the upper wall at every step t≡1(mod3) as the proof says, and its average regret is within 5% of 2(C−2)/3; (ii) the bias-corrected and ε = 10−8 variants keep at least half of that regret; (iii) AMSGrad, SGD and AdaGrad end below 5% of it. A confirmation: it is a theorem, and the pilot had already shown it.
DesignC∈{2.5,3,5,10,100}, 30,000 steps,
α=0.91−β2 with
αt=α/t, six arms, deterministic.
The second test is the paper's own experiment: a gradient of 1010 once in 101 steps and −10 otherwise, with β₁ = 0.9 and β₂ = 0.99, where "its iterates x_t converge to x = 1, which unfortunately has the largest regret amongst all points in the domain", and a stochastic version, 1010x with probability 0.01. The step size and the starting point are not stated.
ClaimAdam's iterate goes to +1 and AMSGrad's to the optimum −1, in the online and the stochastic versions.
HypothesisIn at least 80% of cells Adam ends above 0, and AMSGrad ends below 0 in at least 3 of the 10 (α, schedule) cells for each starting point.
Designα∈{0.1,0.03,0.01,0.003,0.001}, constant or
α/t,
x1∈{0,1}, 300,000 steps; the stochastic version with 5 seeds per cell, judged by the median.
21Research desk
How far apart can the large gradients be before Adam goes the wrong way?
Reddi et al. choose the problem after the hyperparameters; a practitioner fixes the problem and then chooses β₂. Défossez et al. note that the counterexamples use a β₂ below 1/5 [9], and Zhang et al. prove that for large enough β₂ Adam converges [10]. Neither says how large is large enough for a gradient that is rare. The experiment asks it directly.
ClaimAdam converges when β₂ goes to 1; "the optimization algorithm must have long-term memory of past gradients". How much memory is enough is not stated.
HypothesisTake a gradient of −1 on every step except one in P, where it is S=1.1P−1, so the mean is +0.1 and a good optimiser drifts left. Adam's steady-state drift is right or wrong according to P; the boundary P∗ scales with Adam's memory 1/(1−β2), so κ=(1−β2)P∗ varies by less than a factor of 3 over β2∈{0.9,0.98,0.99,0.999,0.9999}.
Designβ1=0.9 (and 0, the theorem's setting), correction on, 51 values of P from 2 to 251,189, the drift measured over five periods after a burn-in of max(10P,20/(1−β2)) steps. Supported if the largest κ is at most 3 times the smallest; partly if at most 10. Secondary arms: AMSGrad never fails; a stochastic version fails within a factor of 3 of the periodic one.
The law has a reading in steps. A gradient spike sets v, and v forgets it over about 1/(1−β2) steps; during that forgetting the steps grow, and the many small gradients of the wrong sign add up. If the next spike arrives before they have outgrown it, Adam goes the right way; if it arrives later, it does not. For the defaults that is a few hundred steps, for the Transformer's β₂ a few tens.
22Research desk
Figure 4 of the paper, at 151 parameters
Claim"values β2 close to 1 indeed lead to instabilities in training when no bias correction term was present, especially at first few epochs of the training." "In summary, Adam performed equal or better than RMSProp, regardless of hyper-parameter setting." The paper's test: β₁ ∈ {0, 0.9}, β₂ ∈ {0.99, 0.999, 0.9999}, log₁₀α from −5 to −1 on a VAE.
HypothesisH2a: at β₁ = 0.9 and step 100, correction helps by more than 0.05 in loss at 3 of 7 step sizes at β₂ = 0.9999 and makes no difference (under 0.02) at 5 of 7 at β₂ = 0.98. H2b: after 1,000 steps the corrected run is no worse than the uncorrected one by more than 0.02 in 90% of the 56 cells. H2c: with the best α for each, the two differ by at most 0.02 in 7 of 8 (β₁, β₂) pairs. H2d: with correction, β₂ = 0.98 and 0.999 reach the same best loss to within 0.02.
Designlog10α∈{−4,…,−1} in half steps, β1∈{0,0.9}, β2∈{0.98,0.99,0.999,0.9999} (the paper's three plus the Transformer's), correction on or off, seeds 1 to 3: 336 runs, loss over all 200 points after 100 and 1,000 steps.
23Research desk
The size of the step, over a real run
ClaimThe step is "approximately bounded by the stepsize setting α" and "the SNR value typically becomes closer to 0 towards an optimum, leading to smaller effective steps". Neither is tested in the paper. The stated bound is not a bound over all sequences (step 12).
HypothesisH3a: at least 95% of coordinate-steps have ∣Δ∣≤α. H3b: none exceeds the paper's own bound for these settings, 3.16. H3c: the median over coordinates of ∣Δ∣/α, averaged over steps 2,001 to 3,000, is at most a third of its average over steps 1 to 10.
DesignThe paper's β₁, β₂, ε with α = 0.01, 3,000 steps, seeds 1 to 3; at every step the ratio ∣Δt,i∣/α for each of the 151 coordinates (453,000 values per seed).
One of the paper's sentences is not borne out as a description of the typical step. It says that in more common scenarios the ratio is about ±1; The bound is a ceiling that is rarely approached, not the size of a typical step, and only the first few steps of training move the parameters by anything near α.
The stage shows this step's 151 ratios as the step block, with any cell above α in white. At step : are within α and the largest is α.
24Research desk
When ε stops being negligible
ClaimIn the CNN experiment, "the second moment estimate v̂ vanishes to zeros after a few epochs and is dominated by the ε in algorithm 1." And Adam is invariant to the scale of the gradient (step 13), which is exact only when ε = 0.
HypothesisH4a: Adam's final loss changes by at most 0.02 from its value at
c=1 for every
c≥10−4.
H4b: at
c=10−8 it is at least 0.1 worse.
H4c: at
c=1, fewer than 1% of coordinates have
v^<10ϵ at step 1,000, so the §6.3 observation is not reproduced at this scale.
DesignMultiply the loss by c∈{1,10−1,10−2,10−3,10−4,10−6,10−8}; Adam with the paper's defaults and α = 0.01, 1,000 steps, seeds 1 to 3; SGD at α = 0.1 for contrast.
A coordinate whose v^ is far below ε has a step of αm^/ϵ: that is SGD with momentum, at the step size αc/ϵ for the unscaled gradient. At c=10−6 that is 0.01×10−6/10−8=1; at c=10−8 it is 0.01, a tenth of the step size given to SGD in this experiment, where This is the sense in which ε interpolates between Adam and SGD, and the sense in which, in the inclusion argument of Choi et al., Adam can approximate Momentum for large ε [14].
The stage shows the corrected second moment at the step in the bar above and the step it produces: at step , coordinates have a v^ below 10ϵ.
25Research desk
What this adds, and what to test next
In short: the algorithm runs as the paper states, to within PyTorch's arithmetic; its stated bound on the step is exact only for β₁ = 0, and the supremum is larger; its proof had the flaw Reddi et al. say it had, and the counterexample runs as stated at every C tested. The counterexample is a statement about the gap between large gradients relative to Adam's memory, with a constant near 0.3 at the default β₂. On a small network, bias correction mattered at the largest step sizes and in the other direction at smaller ones, and ε takes over when the gradient scale falls by about a million. All of it is at 151 parameters, on one task, with a handful of seeds, which is the scale at which every claim could be checked against every cell.
- How often do real gradients spike, and how far apart? Measure the gaps between large-gradient minibatches in a real training run, per parameter, and compare them to the boundary P∗≈0.3/(1−β2) for the spike sizes seen. That would say whether the counterexample's regime occurs in practice, the question left open by [9] and [10].
- Why does a large early step help here? In E2, uncorrected runs at β₁ = 0 reached the spirals where corrected ones stalled. Test a warm-up schedule and the rectified step of Liu et al. on the same grid, to see whether the early kick is an initial-scale effect of this network or something general about early step size [12].
- An exact law for the boundary. The continuum law is derived for β₂ near 1 and matches the measured brackets at 0.9999; it is looser at short memories. Derive the discrete version and its dependence on β₁.
- How long does AMSGrad need? E1c's AMSGrad cells that did not reach −1 were still moving. Re-run to 107 steps and report the time to cross against α, the one thing the original figure does not show.
- The ε sweep at fixed gradient scale. Sweep ε over several orders of magnitude at the gradient scales where E4 saw it take over, and compare with the tuning protocol of Choi et al., who found that ε matters [14].
The engine, the PyTorch reference and its outputs, the experiments and their results are in this page's directory, anatomy/ai-ml/2026-10-18-adam/; the JavaScript that draws the stage is the code the tests check.
References
- Kingma, D. P. and Ba, J. (2015). Adam: A Method for Stochastic Optimization. ICLR 2015; arXiv:1412.6980v9 The subject of this page. The arXiv source for v9 is a PDF, not LaTeX, so quotes come from its extracted text, checked against the page images where the extraction garbled mathematics.
- Bycroft, B. (2023). LLM Visualization. bbycroft.net/llm The visual grammar of tensors as blocks of cells.
- Duchi, J., Hazan, E. and Singer, Y. (2011). Adaptive subgradient methods for online learning and stochastic optimization. Journal of Machine Learning Research 12, 2121–2159 AdaGrad. Not read for this page; cited only for what Kingma & Ba and Reddi et al. say about it.
- Tieleman, T. and Hinton, G. (2012). Lecture 6.5, RMSProp. COURSERA: Neural Networks for Machine Learning RMSProp, an unpublished lecture. Not read for this page; cited only for what Kingma & Ba say about it.
- PyTorch contributors (2026). torch.optim (Adam, Adamax, SGD, RMSprop, Adagrad). PyTorch 2.14.1, torch/optim/adam.py as installed The independent implementation test.mjs checks the engine against. Its source, not its documentation page, was read.
- Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, Ł. and Polosukhin, I. (2017). Attention Is All You Need. NeurIPS 2017; arXiv:1706.03762 Its optimiser settings, from the arXiv LaTeX source.
- Zinkevich, M. (2003). Online convex programming and generalized infinitesimal gradient ascent. ICML 2003 The online learning framework of the convergence analysis. Not read for this page.
- Reddi, S. J., Kale, S. and Kumar, S. (2018). On the Convergence of Adam and Beyond. ICLR 2018; arXiv:1904.09237 The counterexample and the AMSGrad fix. Quotes from the arXiv LaTeX source.
- Défossez, A., Bottou, L., Bach, F. and Usunier, N. (2022). A Simple Convergence Proof of Adam and Adagrad. Transactions on Machine Learning Research; arXiv:2003.02395 Adam converges, at the rate of AdaGrad, when β₂ is taken to 1 as the horizon grows. Quotes from the arXiv LaTeX source.
- Zhang, Y., Chen, C., Shi, N., Sun, R. and Luo, Z.-Q. (2022). Adam Can Converge Without Any Modification On Update Rules. NeurIPS 2022; arXiv:2208.09632 Reddi et al. pick the problem after the hyperparameters; fix the problem first and Adam converges for large enough β₂. Abstract read from the arXiv LaTeX source.
- Loshchilov, I. and Hutter, F. (2019). Decoupled Weight Decay Regularization. ICLR 2019; arXiv:1711.05101 AdamW. Abstract read from the arXiv LaTeX source.
- Liu, L., Jiang, H., He, P., Chen, W., Liu, X., Gao, J. and Han, J. (2020). On the Variance of the Adaptive Learning Rate and Beyond. ICLR 2020; arXiv:1908.03265 Warm-up as variance reduction for the adaptive step. Abstract read from the arXiv LaTeX source.
- Wilson, A. C., Roelofs, R., Stern, M., Srebro, N. and Recht, B. (2017). The Marginal Value of Adaptive Gradient Methods in Machine Learning. NeurIPS 2017; arXiv:1705.08292 Abstract read from the arXiv LaTeX source.
- Choi, D., Shallue, C. J., Nado, Z., Lee, J., Maddison, C. J. and Dahl, G. E. (2019). On Empirical Comparisons of Optimizers for Deep Learning. arXiv:1910.05446 Abstract read from the arXiv LaTeX source.
- Kingma, D. P. and Welling, M. (2013). Auto-Encoding Variational Bayes. ICLR 2014; arXiv:1312.6114 The VAE of the bias-correction experiment. Not read for this page.
Fact ledger
Every number from the literature on this page, with the sentence it comes from. Hover any underlined number in the text to see its entry.
How this was made
Everything on the stage is computed by engine.js in float64 for the step and settings in the input bar: the gradient of the network by backpropagation, then Adam, Adam in the paper's cheaper ordering, AdaMax, AMSGrad, SGD with and without Nesterov momentum, RMSProp with momentum and AdaGrad. test.mjs (1,293 checks) compares the gradient with PyTorch 2.14.1 autograd (to 2e-16) and finite differences, every optimiser with torch.optim over 60 minibatch steps on three seeds (to 1e-12, moments to 1e-16), and the one-parameter problems of Reddi et al. with torch.optim.Adam; it proves the paper's identities (the unrolled averages, the bias identity, the first step with and without correction, scale invariance, AdaGrad as a limit of Adam, AdaMax's maximum form), derives and simulates the exact supremum of the step, runs Theorem 1 of Reddi et al. as an execution, and recomputes every derived number in the article. Quotes are copied from the arXiv sources (the Adam paper's arXiv source is a PDF, so its quotes come from the extracted text and were checked against the page images where the extraction garbled mathematics). The research desk (pre-registered before any run, committed to the branch first) is reproducible from research/.
Built with the dissection skill. The visual grammar of tensors as blocks of cells owes much to Brendan Bycroft's LLM Visualization. The optimisers are checked against PyTorch's torch.optim. Source, PyTorch reference, tests and experiments: anatomy/ai-ml/2026-10-18-adam/ in the site's repository.
Cite this page
@misc{sigmoid-adam,
title = {Anatomy of Adam},
author = {Praveen T N},
year = {2026},
note = {Sigmoid Anatomy, interactive dissection},
url = {https://praveentn.live/anatomy/adam}
}