Adam Optimizer

Adam (Adaptive Moment Estimation) is a first-order stochastic optimization algorithm that maintains exponentially decaying running averages of both the gradient (first moment) and its element-wise square (second moment), using these to compute per-parameter adaptive learning rates. Key result: combines the benefits of momentum and RMSProp with bias-corrected moment estimates, achieving robust convergence with minimal hyperparameter tuning. Where it applies: training deep neural networks, large-scale machine learning, non-convex stochastic optimization. Who/when: Diederik P. Kingma and Jimmy Ba, 2014 (ICLR 2015).

The Adam optimizer is an algorithm for first-order gradient-based optimization of stochastic objective functions, designed to be computationally efficient, memory-frugal, and invariant to diagonal rescaling of gradients. It updates each parameter using estimates of the first moment (the mean) and the second raw moment (the uncentered variance) of the gradients, normalizing the step so that effective updates have magnitude approximately bounded by the learning rate. Adam matters because it has become the de facto default optimizer in deep learning, dramatically reducing the need for learning-rate scheduling on a wide class of problems. A surprising fact: despite its empirical dominance, the original convergence proof for Adam in the convex online setting was later shown to be flawed, and counterexamples exist where Adam fails to converge — motivating variants like AMSGrad. The method elegantly unifies Momentum and RMSProp into a single adaptive scheme with principled bias correction.

The Core Insight

Different parameters in a high-dimensional model often have gradients of vastly different scales and statistics. Adam estimates, per coordinate, both the typical direction of descent (via an exponential moving average of gradients — the first moment) and the typical magnitude of fluctuations (via an exponential moving average of squared gradients — the second moment). Dividing the smoothed gradient by the square root of the smoothed squared gradient yields a signal-to-noise normalized step: coordinates with consistent gradients move confidently, while noisy coordinates are damped automatically. Bias correction repairs the systematic underestimation that arises from initializing the moving averages at zero.

Formal Statement

Adam Update Rule

Let be a stochastic objective with parameters , and let be the stochastic gradient at step . Adam maintains two exponential moving averages, (first moment) and (second raw moment), and updates parameters as follows.

The first moment estimate:

1
⟳this is an exponential moving average; expand recursively to see .

The second raw moment estimate (element-wise square ):

2
⟳identical EMA structure applied to squared gradients; .

Bias-corrected estimates:

3
⟳take expectation of assuming stationary gradients; , so divide by to remove bias.

The parameter update:

4
⟳divide the bias-corrected mean step by the bias-corrected RMS magnitude; prevents division by zero.
Symbols: = step size (learning rate, default ); = first-moment decay (default ); = second-moment decay (default ); = numerical stabilizer (default ); = Hadamard (element-wise) product; all divisions and square roots are element-wise. Initialization: , .

Effective Step Bound

Assuming , the magnitude of the effective step taken by Adam in each coordinate satisfies a bound:

5

In the common case (e.g. defaults: ), the bound is , establishing a trust region independent of gradient scale.

⟳bound and a corresponding term; in the sparse-gradient limit the ratio emerges from a single nonzero gradient.

Why It Holds / Derivation

Bias Correction Derivation

We show that the raw moving average underestimates the true second moment, and that the correction in equation [3] removes this bias exactly under a stationarity assumption.

Step 1. Unroll the recursion in equation [2] from :
6
⟳substitute repeatedly; the geometric weights and the leading factor follow by induction.
Step 2. Take the expectation, and assume the second moment is approximately stationary, :
7
where is small if the stationarity assumption holds (it absorbs the drift of across time).
⟳the finite geometric series cancels the leading .
Step 3. The factor is the source of bias — early in training ( small) it can be far below , severely shrinking . Dividing by it yields an unbiased estimate:
8
⟳divide equation [7] by ; the leading term becomes exactly. The identical argument applies to .

Diederik P. Kingma & Jimmy Lei Ba | 2014

Diederik Kingma (then a PhD student at the University of Amsterdam under Max Welling) and Jimmy Ba (then at the University of Toronto under Geoffrey Hinton) introduced Adam in a paper submitted to ICLR 2015. Kingma is also a principal architect of the variational autoencoder (VAE) and normalizing flows; Ba contributed foundational work on layer normalization and attention. The name "Adam" derives from "Adaptive Moment estimation" and is not an acronym in the conventional sense, nor a person's name. Their paper provided both the practical algorithm and an attempted regret-based convergence analysis in the online convex optimization framework of Zinkevich.

Building Intuition

Picture rolling a ball down a noisy, anisotropic landscape. Momentum () gives the ball inertia: it accumulates velocity in consistent directions, smoothing over the jitter of mini-batch noise. The second moment () acts like a per-direction shock absorber: in directions where the gradient is large and erratic, is large, so the update is shrunk; in flat, quiet directions, is small, so the step grows.

The ratio is essentially a signal-to-noise ratio. When gradients agree across mini-batches, and the ratio is near — full-step confidence. When gradients are pure noise with zero mean, while stays positive, so the ratio shrinks and Adam automatically slows down. This is why Adam needs so little manual tuning: it self-normalizes its step to the local geometry. Bias correction matters most in the first few dozen steps, where without it the zero-initialized averages would make the algorithm take dangerously large early steps.

Adam's adaptive step vs. SGD on an ill-conditioned valley

Trajectories on an elongated (ill-conditioned) loss basin minimum SGD (oscillates) Adam (per-axis scaled, smooth descent) start

Worked Examples

Single-Step Update with Numbers

Given: a single parameter , first gradient , defaults , , , , with . Step 1 — first moment: . Step 2 — second moment: . Step 3 — bias correction (): , .
Note that after correction, and exactly — the first step recovers the raw gradient and its square. Step 4 — update:

The effective step is exactly — the trust-region bound of equation [5] is saturated on the very first step regardless of the gradient's actual size.

Noise Suppression Over Many Steps

Given: suppose the gradient at a coordinate is zero-mean noise: it equals on odd steps and on even steps (so the true descent signal is zero, but the magnitude is constant). Compute the steady-state behavior with defaults. Second moment (steady state): since always, , hence . First moment (steady state): oscillates around . After many steps, the EMA of an alternating with has amplitude
(geometric series of alternating signs). After bias correction (factor at large ), . Effective step:

Compare: a consistent gradient of would give , roughly 19× larger. Adam automatically suppresses the step in the noisy direction — its signal-to-noise adaptivity in action.

Common Misconceptions

Adam Is Not Guaranteed to Converge

A widespread belief is that Adam's published convergence proof guarantees convergence on all convex problems. This is false. Reddi, Kale & Kumar (2018, "On the Convergence of Adam and Beyond") identified a flaw in the original regret analysis: the proof incorrectly assumed a positive-semidefinite quantity that can in fact be negative. The effective learning-rate matrix need not be PSD because can decrease. They constructed simple convex problems where Adam converges to the worst possible solution.

A Convex Problem Where Adam Fails

Consider online linear optimization with the periodic loss sequence (period 3), :

for large constant . The optimal fixed decision is (the rare large positive gradient should dominate the two small negative gradients ). However, because Adam's heavily damps the rare large gradient (its squared value is averaged with weight and then divided by , which is dominated by the frequent contributions), the effective influence of the informative gradient is reduced, and Adam drifts toward — the opposite of optimal. This non-vanishing regret is impossible for plain SGD with decaying steps. The fix, AMSGrad, enforces so the denominator is non-decreasing, restoring the PSD property.

Adam ≠ Best Generalization

Empirically, on some tasks (notably image classification with CNNs), well-tuned SGD-with-momentum generalizes better than Adam despite Adam achieving lower training loss faster. Wilson et al. (2017) argue adaptive methods can converge to flatter-but-worse minima or solutions with larger weight norm. This motivated decoupled weight decay (AdamW), where weight decay is applied directly to parameters rather than folded into the gradient, since standard L2 regularization interacts poorly with adaptive per-coordinate scaling.

Connections

Adam sits at the confluence of several optimization lineages. Setting and removing the second-moment normalization recovers classical Momentum (specifically, heavy-ball with EMA). Setting and using only the second moment gives essentially RMSProp, Hinton's unpublished method. The element-wise division by approximates a diagonal preconditioner, linking Adam to Newton's Method and quasi-Newton ideas, though Adam uses only first-order information and a crude diagonal curvature surrogate. Adam is a member of the broader family of Stochastic Gradient Descent methods and is analyzed within Online Convex Optimization via regret bounds. Its bias-correction step has a clean interpretation in terms of Exponential Moving Average estimators. The relationship to Natural Gradient Descent is partial: resembles the diagonal of the empirical Fisher information, though this correspondence is only approximate and the subject of ongoing debate.

Real-World Applications

  • Transformer language models (GPT, BERT, T5): Adam and its variant AdamW are the standard optimizers for pretraining large transformers; the original BERT and GPT papers use Adam with warmup schedules. AdamW is the canonical choice for nearly all modern LLM training.
  • Generative Adversarial Networks (GANs): the DCGAN and StyleGAN families use Adam with reduced (often ) to stabilize the adversarial min-max dynamics.
  • Variational Autoencoders (VAEs): Kingma's own VAE work pairs naturally with Adam for optimizing the evidence lower bound (ELBO).
  • Reinforcement learning (PPO, DQN, A3C): Adam is the default optimizer in most deep-RL implementations due to its robustness to non-stationary objectives and noisy policy gradients.
  • Neural machine translation: the original "Attention Is All You Need" transformer uses Adam with a custom inverse-square-root learning-rate schedule and warmup.
  • Diffusion models (Stable Diffusion, DALL·E): trained with AdamW over very long horizons; Adam's adaptivity handles the heterogeneous gradient scales across U-Net depths.
  • Recommendation systems and sparse embeddings: Adam's per-coordinate scaling handles the extreme gradient sparsity of large embedding tables, where most parameters receive gradients only rarely.

Historical Development

  • 1951 — Robbins & Monro introduce the stochastic approximation framework, the theoretical bedrock of all SGD methods.
  • 1964 — Polyak introduces the heavy ball momentum method, the ancestor of Adam's first-moment term.
  • 2011 — Duchi, Hazan & Singer publish AdaGrad, the first widely used per-coordinate adaptive method, accumulating the full sum of squared gradients.
  • 2012 — Tieleman & Hinton present RMSProp (in a Coursera lecture, never formally published), replacing AdaGrad's accumulation with an exponential moving average — directly the second-moment idea Adam reuses.
  • 2012 — Zeiler publishes AdaDelta, another EMA-based adaptive method addressing AdaGrad's vanishing learning rate.
  • December 2014 — Kingma & Ba post the Adam paper to arXiv; it is accepted to ICLR 2015, and rapidly becomes the most-cited optimization method in deep learning.
  • 2016 — Dozat introduces Nadam, incorporating Nesterov-accelerated momentum into Adam.
  • 2018 — Reddi, Kale & Kumar (ICLR) expose the convergence flaw and propose AMSGrad; Loshchilov & Hutter propose AdamW with decoupled weight decay.
  • 2019–2021 — A wave of variants: RAdam (rectified variance), LAMB (layer-wise scaling for huge batches), AdaBelief, Lion; debate continues over Adam's generalization properties versus SGD.

Subtleties & Limits

Several deep questions about Adam remain only partially resolved. (1) Generalization gap: there is still no complete theory explaining when and why SGD generalizes better than Adam, nor a sharp characterization of the minima each method selects in non-convex landscapes. (2) Non-convex convergence guarantees: rigorous convergence rates for Adam (and variants) on smooth non-convex objectives require additional assumptions (e.g. bounded gradients, specific relationships) and the constants are often vacuous; the precise role of in convergence is subtle. (3) The Fisher-information interpretation: whether should be viewed as a principled approximation to natural-gradient preconditioning, or merely an effective heuristic, is contested. (4) Hyperparameter coupling: the interaction between , , weight decay, and learning-rate warmup is poorly understood theoretically, despite enormous practical importance — RAdam's analysis of early-training variance is one partial answer. (5) Optimal scaling with batch size and sequence length for billion-parameter models remains largely empirical.

See Also

Momentum · RMSProp · AdaGrad · Stochastic Gradient Descent · Online Convex Optimization · Natural Gradient Descent · AMSGrad · AdamW · Nadam · Exponential Moving Average

Before this

Where this leads

  • AMSGrad — the fix for Adam's convergence failure via non-decreasing second moments.
  • AdamW — decoupled weight decay, the standard optimizer for modern large models.
  • Natural Gradient Descent — a deeper, geometry-aware view of adaptive preconditioning.
  • Learning Rate Scheduling — warmup and decay strategies that complement Adam in practice.
  • Second-Order Optimization — quasi-Newton and K-FAC methods that go beyond Adam's diagonal curvature surrogate.