# Adam: A Method for Stochastic Optimization

Diederik P. Kingma, Jimmy Ba · arXiv · 2014-12-22

- **Problem** Stochastic objectives with high-dimensional parameters need first-order optimizers that stay cheap in memory and cope with noisy, sparse and non-stationary gradients.
- **Method** Adam keeps exponential moving averages of the gradient and of its square, corrects both for their zero initialization, and divides the first by the square root of the second to set a per-parameter step.
- **Results** On CIFAR-10 convolutional networks, Adam and SGD with Nesterov momentum converged considerably faster than Adagrad over 45 epochs, and on MNIST logistic regression Adam matched SGD with Nesterov momentum and beat Adagrad.

## Why a cheap first-order optimizer is needed

Many training problems reduce to optimizing a scalar objective over its parameters, and for a differentiable objective the first-order partial derivatives cost about as much to compute as one evaluation of the function. When the objective is a sum over data subsamples, or carries other noise such as dropout, taking steps along the gradients of individual pieces is the usual route, and this stochastic gradient descent has underpinned many recent deep learning results.

The target here is noisy objectives with high-dimensional parameter spaces, where higher-order methods are judged ill-suited, so the discussion stays with first-order methods. Adam is meant to use only first-order gradients and little extra memory, and it computes a separate adaptive learning rate for each parameter from running estimates of the first and second moments of the gradients.

## The moment-based update rule

At each timestep the gradient \\(g\_t\\) of the stochastic objective \\(f\_t\\) is evaluated at the previous parameters \\(\\theta\_{t-1}\\), and two exponential moving averages are updated: \\(m\_t = \\beta\_1 m\_{t-1} + (1-\\beta\_1) g\_t\\) for the gradient and \\(v\_t = \\beta\_2 v\_{t-1} + (1-\\beta\_2) g\_t^2\\) for its elementwise square. Both averages start at zero, and the decay rates \\(\\beta\_1, \\beta\_2 \\in \[0,1)\\) decide how quickly older gradients are forgotten; the first average estimates the mean of the gradient and the second estimates its uncentered second moment.

Because both averages start at zero, they are rescaled by \\(\\hat m\_t = m\_t/(1-\\beta\_1^t)\\) and \\(\\hat v\_t = v\_t/(1-\\beta\_2^t)\\) before use. The parameter update is then \\(\\theta\_t = \\theta\_{t-1} - \\alpha \\hat m\_t/(\\sqrt{\\hat v\_t} + \\epsilon)\\), so the step direction comes from the averaged gradient and its size is scaled by the averaged squared gradient.

A reordered form folds the bias correction into a step size \\(\\alpha\_t = \\alpha\\sqrt{1-\\beta\_2^t}/(1-\\beta\_1^t)\\), which is cheaper to compute though less transparent.

## How the step size behaves

With \\(\\epsilon = 0\\), the effective step in parameter space is \\(\\Delta\_t = \\alpha \\hat m\_t/\\sqrt{\\hat v\_t}\\), and the paper gives two upper bounds on its size that depend on whether \\(1-\\beta\_1\\) exceeds \\(\\sqrt{1-\\beta\_2}\\). The first bound applies only in the most extreme sparsity, when a gradient has been zero at every timestep except the current one; with less sparse gradients the effective step is smaller.

The ratio \\(\\hat m\_t/\\sqrt{\\hat v\_t}\\) is called the signal-to-noise ratio, and when the gradient is consistent its magnitude is close to one, so the step size is roughly \\(\\alpha\\) in size. A small ratio means the direction of \\(\\hat m\_t\\) is uncertain, and the step shrinks accordingly; the authors note that this ratio typically moves toward zero near an optimum, which gives an automatic annealing effect.

Since \\(\\alpha\\) bounds the typical step, it gives a trust region around the current parameters, which makes the right order of magnitude for \\(\\alpha\\) easier to guess in advance. Scaling the gradient by a factor \\(c\\) scales \\(\\hat m\_t\\) by \\(c\\) and \\(\\hat v\_t\\) by \\(c^2\\), so for \\(c \> 0\\) the ratio \\(\\hat m\_t/\\sqrt{\\hat v\_t}\\) is unchanged and the effective step does not depend on the gradient scale.

## Why the moments are bias-corrected

Unrolling the recursion writes \\(v\_t\\) as a weighted sum of all past squared gradients with weights \\((1-\\beta\_2)\\beta\_2^{t-i}\\). Taking expectations gives \\(E\[v\_t\] = E\[g\_t^2\](1-\\beta\_2^t) + \\zeta\\), where \\(\\zeta\\) vanishes if the second moment of the gradient is stationary, so the factor \\(1-\\beta\_2^t\\) is the part caused by starting from zeros.

Dividing by \\(1-\\beta\_2^t\\) therefore removes that bias, and the authors argue that \\(\\zeta\\) can be kept small by choosing the decay rate so that old gradients receive little weight. The correction matters most when \\(\\beta\_2\\) is small, which is the setting needed for reliable second-moment estimates under sparse gradients, because without it the first steps would be much larger.

## Regret bound in the online convex setting

The analysis uses the online learning framework of Zinkevich, where an arbitrary sequence of convex costs \\(f\_1, \\ldots, f\_T\\) is revealed and the learner must choose \\(\\theta\_t\\) before seeing \\(f\_t\\). Performance is measured by regret, \\(R(T) = \\sum\_{t=1}^{T}\[f\_t(\\theta\_t) - f\_t(\\theta^\*)\]\\), where \\(\\theta^\* = \\arg\\min\_{\\theta \\in X} \\sum\_{t=1}^T f\_t(\\theta)\\) is the best fixed parameter in the feasible set \\(X\\).

The main theorem assumes bounded gradients in the \\(\\ell\_2\\) and \\(\\ell\_\\infty\\) norms, bounded distances between iterates, and \\(\\beta\_1^2/\\sqrt{\\beta\_2} \< 1\\), which is written as \\(\\gamma\\) in the analysis.

The bound has three terms: one that depends on \\(D\\), \\(\\alpha\\), \\(\\beta\_1\\) and the final \\(\\hat v\_{T,i}\\) scaled by \\(\\sqrt{T}\\); one that depends on \\(G\_\\infty\\), the gradient norms \\(\\\|g\_{1:T,i}\\\|\_2\\) and \\((1-\\gamma)^2\\); and one that depends on \\(D\_\\infty\\), \\(G\_\\infty\\) and \\((1-\\lambda)^2\\). When the data features are sparse, the sum of gradient norms can be far below its worst-case value \\(dG\_\\infty\\sqrt{T}\\), so the adaptive methods Adam and Adagrad reach \\(O(\\log d\\sqrt{T})\\) regret, an improvement over \\(O(\\sqrt{dT})\\) for a non-adaptive method.

Decaying \\(\\beta\_{1,t}\\) toward zero is central to this analysis, and it agrees with the observation of Sutskever et al. that reducing the momentum coefficient late in training can help convergence. Corollary 4.2 combines the theorem with the bound \\(\\sum\_{i}\\\|g\_{1:T,i}\\\|\_2 \\le dG\_\\infty\\sqrt{T}\\) to show \\(R(T)/T = O(1/\\sqrt{T})\\), so the average regret tends to zero.

## Relation to AdaGrad and RMSProp

Adam resembles natural gradient descent in that \\(\\hat v\_t\\) approximates the diagonal of the Fisher information matrix, but its preconditioner is more conservative than the vanilla natural gradient, as is AdaGrad's. Its main relation to RMSProp is that RMSProp uses momentum on the rescaled gradient, whereas Adam averages the gradient and its square directly, and RMSProp has no bias correction, which matters when \\(\\beta\_2\\) is close to one.

The authors note that this correspondence breaks down without the bias-correction terms: without them, a \\(\\beta\_2\\) infinitesimally close to one would produce unboundedly large bias and parameter updates.

## Logistic regression results

The MNIST experiment uses L2-regularized multi-class logistic regression on 784-dimensional image vectors, with minibatch size 128 and a stepsize decayed as \\(\\alpha\_t = \\alpha/\\sqrt{t}\\). Adam yields convergence similar to SGD with Nesterov momentum, and both converge faster than AdaGrad.

The sparse case uses the first 10,000 most frequent words of IMDB reviews as bag-of-words features, with 50% dropout noise applied to these inputs during training. Figure 1 shows that AdaGrad outperforms SGD with Nesterov momentum by a large margin with and without dropout, and Adam converges as fast as AdaGrad; the authors tie this to the sparse-feature advantage that AdaGrad has in theory.

## Multilayer networks and the SFO comparison

The networks have two fully connected hidden layers of 1000 ReLU units each and are trained with minibatch size 128; the first comparison uses a deterministic cross-entropy objective with L2 weight decay. Against the Sum-of-Functions Optimizer, Adam makes faster progress in both iterations and wall-clock time, and SFO is 5-10x slower per iteration and needs memory linear in the number of minibatches.

With dropout, SFO failed to converge, because it assumes deterministic subfunctions. Among the stochastic first-order methods compared on the dropout-trained networks, Adam shows the better convergence.

## Convolutional networks on CIFAR-10

The CNN has three alternating stages of 5x5 convolution filters and 3x3 max pooling with stride 2, followed by a fully connected layer of 1000 ReLU units, with whitened inputs and dropout on the input and fully connected layers. The architecture is c64-c64-c128-1000 on CIFAR-10, and the minibatch size is again 128.

AdaGrad and Adam both make rapid early progress, but Adam and SGD with Nesterov momentum eventually converge considerably faster than AdaGrad over 45 epochs. Adam shows only a marginal gain over SGD with momentum, but it adapts the learning rate per layer instead of requiring hand tuning as SGD does.

## Bias correction on variational auto-encoders

Figure 4 compares the loss with and without bias correction after 10 and 100 epochs. Removing the correction is a version of RMSProp with momentum, as the authors note.

Values of \\(\\beta\_2\\) close to one lead to instabilities without the correction, especially in the first epochs of training. The best results came from small values of \\(1-\\beta\_2\\) with bias correction, and the authors state that Adam performed equal or better than RMSProp regardless of the hyper-parameter setting.

## AdaMax and temporal averaging

Adam's per-weight scaling can be generalized from the L2 norm to an Lp norm, but these variants become numerically unstable for large p. Letting p go to infinity gives the exponentially weighted infinity norm \\(u\_t = \\max(\\beta\_2 u\_{t-1}, \|g\_t\|)\\) with \\(u\_0 = 0\\), which needs no initialization bias correction.

AdaMax updates parameters as \\(\\theta\_t = \\theta\_{t-1} - (\\alpha/(1-\\beta\_1^t)) m\_t/u\_t\\), with suggested defaults \\(\\alpha = 0.002\\), \\(\\beta\_1 = 0.9\\) and \\(\\beta\_2 = 0.999\\). The magnitude of AdaMax parameter updates has the simpler bound \\(\|\\Delta\_t\| \\le \\alpha\\), compared with the bound on Adam's effective step.

For temporal averaging, the authors recall Polyak-Ruppert averaging for SGD and propose an exponential moving average over the parameters, \\(\\bar\\theta\_t \\leftarrow \\beta\_2 \\bar\\theta\_{t-1} + (1-\\beta\_2)\\theta\_t\\), with bias correction \\(\\hat\\theta\_t = \\bar\\theta\_t/(1-\\beta\_2^t)\\). This averaging is described as a single extra line in the inner loop, and the experiments in the units do not evaluate it.

## Limits of the evidence

The regret analysis requires convex losses in the online setting, and the authors state that it does not apply to the non-convex multilayer networks they test, where Adam nonetheless performed well empirically. The theorem also assumes bounded gradients, bounded distances between iterates and \\(\\beta\_1^2/\\sqrt{\\beta\_2} \< 1\\), so the guarantee holds only under those conditions.

The empirical comparisons report the best hyper-parameter setting found on a dense grid, so each method is compared at its tuned best. The experiments cover logistic regression on MNIST and IMDB, a multilayer network, one CNN architecture on CIFAR-10 and one variational auto-encoder; the bias-correction study covers only the variational auto-encoder.

The authors' explanation of AdaGrad's slower CNN convergence rests on the vanishing second-moment observation, and the units contain no separate test of that explanation.

## Paper info

- **Authors**: Diederik P. Kingma, Jimmy Ba
- **Venue**: arXiv · Preprint
- **First published**: 2014-12-22
- **Added**: 2026-10-20
- **Updated**: 2017-1-30
- **Version**: v9
- **arXiv**: 1412.6980
- **Category**: cs.LG
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/1412.6980v9) · [PDF ↗](https://arxiv.org/pdf/1412.6980v9)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Diederik P. Kingma, Jimmy Ba (2014). Adam: A Method for Stochastic Optimization. arXiv:1412.6980v9. https://arxiv.org/abs/1412.6980v9

**BibTeX**

```
@misc{kingma2014adam,
  title = {{Adam: A Method for Stochastic Optimization}},
  author = {Diederik P. Kingma and Jimmy Ba},
  year = {2014},
  eprint = {1412.6980},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1412.6980v9}
}
```

## Other paper commentary

- [Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift](https://refivu.com/en/papers/bd3e1105-da91-407a-8b28-4217cd2afedf-batch-normalization-accelerating-deep-network-training-by.md)
- [Instance Normalization: The Missing Ingredient for Fast Stylization](https://refivu.com/en/papers/d30fae5e-d1ad-4ef1-9b41-da9a7a9f25cf-instance-normalization-the-missing-ingredient-for-fast.md)
- [Group Normalization](https://refivu.com/en/papers/73ea525c-b90c-43b2-b656-bb21666ab914-group-normalization.md)
- [Layer Normalization](https://refivu.com/en/papers/2f67f179-7720-4b69-8cac-e7157bee38ae-layer-normalization.md)
- [Root Mean Square Layer Normalization](https://refivu.com/en/papers/97c61522-5940-4a28-ad7d-4126a3ce8c01-root-mean-square-layer-normalization.md)
- [Expectile Regularization for Fast and Accurate Training of Neural Optimal Transport](https://refivu.com/en/papers/eed71a11-0424-45c6-8f8e-e7d5e94053d5-expectile-regularization-for-fast-and-accurate-training-of.md)
- [BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding](https://refivu.com/en/papers/037751cf-a504-48c3-b08a-868e3ab40b26-bert-pre-training-of-deep-bidirectional-transformers-for.md)
- [Attention Is All You Need](https://refivu.com/en/papers/9645c9a1-cc92-404a-bc65-1ec437b1deab-attention-is-all-you-need.md)
- [FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning](https://refivu.com/en/papers/177a3817-56f7-448e-964a-a2e688dc7c81-flashattention-2-faster-attention-with-better-parallelism.md)

## Terms in this paper

- [CIFAR-10](https://refivu.com/en/terms/19035a518d0a-cifar-10)
- [MNIST](https://refivu.com/en/terms/28b9bb66d1c6-mnist)
- [dropout](https://refivu.com/en/terms/db73f75bbdd3-dropout)
- [Stochastic Gradient Descent](https://refivu.com/en/terms/a49650824022-stochastic-gradient-descent)
- [Convolutional Neural Networks](https://refivu.com/en/terms/936419759d72-convolutional-neural-networks)
- [Adagrad](https://refivu.com/en/terms/d6141e5e2b98-adagrad)
- [Logistic Regression](https://refivu.com/en/terms/3551369d301a-logistic-regression)
- [RMSProp](https://refivu.com/en/terms/a1984fdf7b1d-rmsprop)
- [Fisher information matrix](https://refivu.com/en/terms/805248ff459f-fisher-information-matrix)
- [AdaMax](https://refivu.com/en/terms/7c04522a9c5d-adamax)
- [regret](https://refivu.com/en/terms/5f1abfbe36f2-regret)
- [signal-to-noise ratio](https://refivu.com/en/terms/9b3a8b590fb6-signal-to-noise-ratio)
- [Polyak-Ruppert averaging](https://refivu.com/en/terms/3b0881156b3d-polyak-ruppert-averaging)
- [SGD with Nesterov momentum](https://refivu.com/en/terms/ed57b408234e-sgd-with-nesterov-momentum)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/1e4ce3cf-c297-4440-9078-a86a09a9caca-adam-a-method-for-stochastic-optimization)
