TL;DR
Adam is the default optimizer for training deep networks, and it is usually reliable. This paper shows that its convergence proof was wrong, and that Adam can fail to reach the best answer even on a one-dimensional convex problem. The cause is the exponential moving average of squared gradients: it forgets a rare large gradient so fast that the step size grows back. The authors propose AMSGrad, which keeps the largest value of that average seen so far, so the step size can only shrink, and they prove a regret bound for it.
Builds on: Adam Optimizer, Exponential Moving Average, No-Regret Learning · Leads to: AMSGrad, AdamW Optimizer
Why it mattered
Adam and RMSprop became the standard optimizers for training language models, image networks and recommender systems, and most of the practical tuning advice around them was built on the belief that Adam converges. This paper pointed to a gap between that belief and the mathematics, and it made the failure concrete with a counterexample that a reader can check by hand.
The fix, AMSGrad, changes one line of Adam and keeps its per-parameter step sizes. It is now available in common deep learning libraries as an option. The paper's wider lesson, that an adaptive method needs a step size that does not grow back without limit, shaped later work on adaptive optimizers.
The problem
Plain Stochastic Gradient Descent uses one step size that shrinks over time, and it converges but often slowly. Adaptive methods such as AdaGrad divide each coordinate's step by the root of a sum of its past squared gradients, so coordinates with large gradients take smaller steps. Adagrad's sum only grows, so its step sizes only shrink, which makes convergence safe but can make learning too slow for deep networks.
Adam and RMSprop replace the sum with an exponential moving average, so old gradients fade and the step size can recover. The paper asks what that fading costs. Write the step-size inverse as , where is the moving average of squared gradients. Its change from one step to the next, , is never negative for SGD or Adagrad, which means their step sizes never grow. For Adam it can be negative, and the paper shows that this is exactly when convergence breaks.
How it works
The paper's counterexample is a sequence of linear losses on the interval . Let the gradient be on every third step and on the other two, with . The best fixed point is : the gradients sum to a positive slope over each cycle, so the loss is lowest at the left end of the interval. Adam with and moves to instead, which is the worst point.
- Feed a large gradient. On a step with gradient , the second-moment average jumps up by , which with is almost all of . The step is scaled down, so the large gradient is informative but its effect is small.
- Forget it quickly. On the next two steps the gradient is , and each step multiplies the old average by . The large gradient's contribution fades, so the step size grows back.
- Move the wrong way. The two small gradients of push upward, and with a large step size again, Adam pushes toward . The rare large gradient that points toward arrives too late and too weakly to reverse this.
- Repeat. Each cycle of three steps repeats the pattern, so the iterate stays near the worst point. Its average regret, the total loss minus the loss of the best fixed point in hindsight, divided by the number of steps (see No-Regret Learning), does not go to zero.
AMSGrad changes one thing. It keeps the running maximum and divides by instead of . A spike in is then remembered for as long as it stays the largest value seen, so the step size cannot grow back in step 2 above.
- Adam v_t
- AMSGrad v-hat_t
Worked examples
Use the counterexample with , so and . The gradients on steps 1, 2 and 3 are , and , because step 1 is the step with . Start from . Find , and .
- Step 1: .
- Step 2: .
- Step 3: .
- Check: the spike's share fell from 8.1 to 1.71 to 1.071, so by step 3 the average is only a little above what the small gradients alone would give.
Interpretation: after one spike of size 3, Adam's average has dropped to about a seventh of its peak within two steps. The next step size is no longer damped by the spike.
Continue the same sequence to step 4, where the large gradient returns, and compare Adam's with AMSGrad's .
- Step 4: , so .
- Adam's value on step 4 is , which is almost the same as the spike on step 1, because the average was reset by the new large gradient.
- AMSGrad's value: , , , and .
- Check: never falls in this run, so the AMSGrad step size on steps 2 and 3 uses 8.1, not 1.71 or 1.071.
Interpretation: AMSGrad's steps on the small gradients are about times smaller than Adam's on step 2, which is the damping that prevents the drift toward .
The paper's synthetic experiment uses on steps with and otherwise, on . Find the best point and explain why an algorithm that trusts the typical gradient can be misled.
- Over one period of 101 steps, the total gradient coefficient is .
- The average is , which is positive. A linear loss with positive average slope is smallest at the left end, so the best point is .
- Most steps push toward , since their gradient is with a negative coefficient. Only one step in 101 pushes toward , and it is the large one.
- Adam's step on the rare spike is damped by the average it has built up, so the many small steps win and drifts to . AMSGrad keeps the spike in its maximum and so keeps the big correction in effect.
- Try it: if the spike were instead of and the rest unchanged, what is the best point? Answer: the total is , which is negative, so the average slope is negative and the best point is . The optimum is set by the size of the rare spike, which an adaptive method has to notice.
The math
Notation: is the gradient at step . Adam keeps a first-moment average and a second-moment average , with . The iterate is , where projects back onto the feasible set and is the step size.
Step 1 in symbols: the large gradient enters
With the first moment is just . The second moment after the large gradient is . With the new term is , a little less than .
Step 2 in symbols: the forgetting
After the large gradient, each step multiplies the old value by . Over steps the large gradient's share of is multiplied by . Adam's step on a later small gradient is , which is large whenever has forgotten the spike.
Step 3 in symbols: the indefinite
The paper's key quantity is . For a non-increasing learning rate this is nonnegative. Adam's moving average does not guarantee that, so can be negative, and the convergence proof of Adam, which assumed nonnegativity, does not apply. Theorem 1 of the paper gives a convex problem where Adam's average regret does not go to zero.
Step 4 in symbols: AMSGrad
Because never decreases, the effective step size is non-increasing, so holds for every even with a constant . Theorem 4 bounds the regret of AMSGrad by a sum of three terms: one proportional to times the sum of the square roots of the final , one from the momentum decay, and one from the gradient history. With the more modest momentum decay , the bound is (Corollary 1), which the paper compares with the regret of SGD: the AMSGrad bound can be better when the final are small.
Results
The paper's theorems are the main results. Theorem 1 shows a convex online problem, the one in the counterexample, where Adam's average regret does not go to zero. Theorem 2 extends this to any constant with , and Theorem 3 gives a stochastic version in which Adam does not converge to the optimum. The paper also states that adding a small constant to the denominator does not remove the problem for constant (Theorem 6 in its appendix). Theorem 4 proves the regret bound for AMSGrad, and Corollary 1 gives the form under a decaying momentum schedule.
The experiments are preliminary, and the paper says so. On the synthetic problem, Adam's average regret stays away from zero and its iterate converges to , while AMSGrad's regret goes to zero and its iterate reaches . On multiclass logistic regression on MNIST, with minibatches of 128 and , the paper reports AMSGrad with lower training and test loss than Adam. The paper also compares the two on a one-hidden-layer network with 100 ReLU units on MNIST (Figure 2, with constant step size and a grid search over parameters). On the Cifarnet convolutional network on CIFAR-10, the paper reports AMSGrad performs considerably better than Adam on training loss and accuracy, and that the gain carries over to test loss. The paper reports that AMSGrad was less sensitive to the choice of parameters.
The limits are important. The counterexamples are constructed, and the authors say that real training is not one of them, although they argue such behaviour could slow learning. The regret bound is for convex problems. Theorem 4 allows , so a constant is covered, but the bound's form needs the decaying schedule . The paper's own AdamNc variant changes over time to get a convergence bound without changing the algorithm's structure. Nothing here proves that AMSGrad is the best fix for deep networks. It proves that Adam as stated can fail, and that a simple change removes the failure on the problems studied.
Reading guide
- Section 1, Introduction: the story of adaptive methods, from AdaGrad to Adam Optimizer and RMSProp. Read it with the Exponential Moving Average lesson in mind.
- Section 2, Preliminaries: the online setting and regret. No-Regret Learning explains why average regret going to zero is the target. The generic adaptive framework in Algorithm 1 is the template that Adam and AMSGrad both fit.
- Section 3, The Non-Convergence of Adam: the counterexample and Theorems 1 to 3. Work through the three-step cycle of Example 1 before reading the proof sketch. The condition is the one to watch.
- Section 4, AMSGrad: Algorithm 2 and Theorem 4. The one-line change is the maximum . AMSGrad has the algorithm in full.
- Section 5, Experiments: the synthetic problem, then logistic regression, a small network and Cifarnet. The Logistic Regression and Cross-Entropy Loss lessons cover the first experiment's model.
- Appendix: the proofs. Read them only after Section 4 is clear.
Check yourself
QuestionIn one sentence, what does Adam get wrong in the counterexample, and what does AMSGrad change to fix it?Show answer
Adam lets a rare large gradient's effect in its second-moment average fade within a few steps, so the step size grows back and small gradients push the iterate to the worst point. AMSGrad keeps the running maximum of the second-moment average and divides by that, so the step size cannot increase after a large gradient, and stays nonnegative.
QuestionWith beta2 = 0.1 and the second-moment average at 8.1 after a spike, what is the value after two steps of gradient -1, with the average starting from 8.1 at step 1?Show answer
Step 2 gives . Step 3 gives . After two small steps the average is 1.071, so the spike's contribution has fallen by a factor of about eight.
QuestionWhy does the paper's Gamma quantity matter for convergence?Show answer
Gamma is the change in the inverse learning rate from one step to the next. When it is nonnegative, the learning rate never grows, and the standard regret argument works. Adam's moving average can make Gamma negative, which breaks the assumption in its published proof and allows the step size to grow back.
QuestionIn the synthetic problem with a spike of 1010 and small slope -10 on 100 of 101 steps, why is the best point -1 even though most steps push toward +1?Show answer
The average over a period is , a positive slope. For a linear loss with positive average slope the minimum over is at . The rare large gradient carries enough total weight to outweigh the many small ones, so a method must keep that weight in its steps.