On the Convergence Proof of AMSGrad and a New Version
Tran Thi Phuong, Le Trieu Phong
Introduction and our contributions
One of the most popular algorithms for training deep neural networks is stochastic gradient descent (SGD) and its variants. Among the various variants of SGD, the algorithm with the adaptive moment estimation Adam is widely used in practice. However, Reddi et al. have recently shown that the convergence proof of Adam is problematic and proposed a variant of Adam called AMSGrad to solve this issue.
Our contribution. In this paper, we point out a flaw in the convergence proof of AMSGrad. We then fix this flaw by providing a new convergence proof for AMSGrad in the case of special parameters. In addition, in the case of general parameters, we propose a new and slightly modified version of AMSGrad.
To provide more details, let us recall AMSGrad in Algorithm 1, in which the mathematical notation can be fully found in Section 2.
Let and be the sequences obtained from Algorithm 1, , , for all and . Assume that has bounded diameter and for all and . For generated using AMSGrad (Algorithm 1), we have the following bound on the regret:
In their proof for Theorem A, Reddi et al. resolved an issue on the so-called telescopic sum in the convergence proof of Adam ([2, Theorem 10.5]). Specifically, Reddi et al. adjusted such that all components in the vector
are always positive. However, there is another issue (showed in Section 3) in the convergence proof of Adam that AMSGrad unfortunately neglects. The issue affects both the correctness of Reddi et al.’s proof and the upper bound for the regret in Theorem A. To deal with the issue in a general way, we propose to modify Algorithm 1 such that all components in the vector
are always positive. The differences with (1.0.1) are highlighted in the boxes for clarity.
Paper roadmap. We begin with preliminaries in Section 2. We show where the proof of Theorem A becomes invalid in Section 3. After that, we suggest two ways to resolve the issue in Sections 4 and 5.
Subsequent works. The first version of this paper publicly appeared on arXiv on 7 April 2019. On 19 April 2019, Reddi et al. revised their original proofshttps://arxiv.org/abs/1904.09237. The revised proof does not suffer from the issue pointed out in Section 3 of this paper, although yielding a constant factor missing in the original claims.
Preliminaries
where .
where denotes the transpose of .
Issue in the convergence proof of AMSGrad
Before showing the issue in the convergence proof of AMSGrad, let us recall and prove the following inequality, which also appears in .
Algorithm 1 achieves the following guarantee, for all :
and for all . For all , put . Using Lemma 2.8 with and , we have
Moreover, by Lemma 2.2, we have , where denotes the transpose of vector . This means that
On the other hand, for all , we have
where the inequality is from the fact that for any . Hence,
Since , we obtain
where the last inequality is from the assumption that . Therefore,
and we obtain the desired bound for . ∎
Issue in the convergence proof of AMSGrad. We denote the terms on the right hand-side of the upper bound for in Lemma 3.1 as
The issue in the proof of the convergence theorem of AMSGrad [3, Theorem 4] becomes on examining the term (3.1.3). Indeed, in [3, page 18], Reddi et al. usedConcretely, on page 18 of , it is stated that “The […] inequality use the fact that .” the property that , and hence
to replace all by as
However, the first inequality (in red) is not guaranteed because the quantity
in (3.1.3) may be both negative and positive as shown in Example 3.2. This is also a neglected issue in the convergence proofs in Kingma and Ba [2, Theorem 10.5], Luo et al. [5, Theorem 4], Bock et al. [6, Theorem 4.4], and Chen and Gu [7, Theorem 4.2].
We use the function in the Synthetic Experiment of Reddi et al. [3, Page 6]
with the constraint set . The optimal solution is . By the proof of [3, Theorem 1], the initial point . By Algorithm 1, , , and . We choose , , where , , and , where . Under this setting, we have , , and hence
Since , we have
Since , we obtain
Outline of our solution. Let us rewrite (3.1.3) as
Omitting the term , we obtain
in which the differences with Reddi et al. are highlighted in the boxes, namely, and instead of .
We suggest two ways to overcome these differences depending on the setting of :
In Section 4: If either or , , where and , then we give a new convergence theorem for AMSGrad in Section 4.
In Section 5: If the setting for is general, as in the statement of Theorem A, then we suggest a new (slightly modified) version for AMSGrad in Section 5.
New convergence theorem for AMSGrad
When either or , , where and , Theorem A can be fixed as follows, in which the upper bounds of the regret are changed.
Let and be the sequences obtained from Algorithm 1, , either , where , or for all and . Assume that has bounded diameter and for all and . For generated using AMSGrad (Algorithm 1), we have the following bound on the regret. Then, there is some such that AMSGrad achieves the following guarantee for all :
provided , and
provided .
To prove Theorem 4.1, we need the following Lemmas 4.2, 4.3, and 4.4.
From the definition of in AMSGrad’s algorithm, it is implied that . Therefore, there is some such that . Hence,
where the last inequality is by Lemma 2.4. ∎
If either or , then there exists some such that for every ,
Since , it is sufficient to prove that there exists some such that for every ,
When , from (4.3.1) we have
When , (4.3.1) have the following form
Since and are smaller than , it is easy to see that when is sufficiently large, meaning that for some , the left-hand side of (4.3.2) is and the left-hand side of (4.3.3) is larger than . Therefore, (4.3.2) and (4.3.3) hold when is sufficiently large. ∎
For the parameter settings and conditions assumed in Theorem 4.1, we have
The proof is almost identical to that of [3, Lemma 2]. Since for all , , we have
where the second inequality is by Lemma 2.3, the third inequality is from the properties of and for all , and the fourth inequality is obtained by applying Lemma 2.4 to . Therefore,
where the second inequality is by Lemma 2.7. Therefore
It is sufficient to consider . Firstly, can be expanded as
Changing the role of as the common factor, we obtain
where the last inequality is by Lemma 2.4, we obtain
where the first inequality is by Lemma 2.3 and the last inequality is by Lemma 2.5, we obtain
To prove Theorem 4.1, by Lemma 3.1, we need to bound the terms (3.1.3), (3.1.4), and (3.1.5). First, we consider (3.1.4). We have
where the equality is by the assumption that and the last inequality is by Lemma 4.4. Next, we consider (3.1.5). The bound for (3.1.5) depends on either or . Recall that by assumption, for any , . If , then,
where the first inequality is from Lemma 4.2 and the assumption that , the last inequality is by Lemma 2.4. If , then,
where the first inequality is from Lemma 4.2 and the assumption that , and the last inequality is by Lemma 2.6.
Finally, we will bound (3.1.3). From the inequality (3) and replacing with , we obtain
By Lemma 4.3, there is some such that for all . Therefore,
where the second inequality is obtained by omitting the term , and the last inequality is by Lemma 4.2 and the assumption that . Summing up, if , then, from (4), (4), and (4), we obtain
If , then, from from (4), (4), and (4), we obtain
The following corollary shows that, when either or , , where and , the average regret of AMSGrad converges.
With the same assumption as in Theorem 4.1, AMSGrad achieves the following guarantee:
The result is obtained by using Theorem 4 and the following fact:
where the inequality is from the assumption that for all . ∎
New version of AMSGrad optimizer: AdamX
With this Algorithm 2, the regret is bounded as follows.
Let and be the sequences obtained from Algorithm 2, , , for all and . Assume that has bounded diameter and for all and . For generated using the AdamX (Algorithm 2), we have the following bound on the regret:
To prove Theorem 5.1, we need the following Lemmas 5.2, 5.3, and 5.4.
We will prove (5.2.1) by induction on . Recall that by the update rule on , we have and if . Therefore,
and the (5.2.1) holds for all . Since
For all , we have , where is in Algorithm 2.
Therefore, there is some such that . Hence,
For the parameter settings and conditions assumed in Theorem 5.1, we have
by Lemma 5.2, we have , and hence the proof is the same as that of Lemma 4.4. ∎
Similarly to the proof of Theorem 4.1, we need to bound (3.1.3), (3.1.4), and (3.1.5). By using Lemma 5.4, we obtain the same bound for (3.1.4) as in the proof of Theorem 4.1, that is,
where the last inequality is by Lemma 5.4. Now we bound (3.1.5). By the assumption that for any , , and , we obtain
Finally, we will bound (3.1.3). By the inequality (3) and replacing , we obtain
Moreover, by the update rule of Algorithm 2, we have
Therefore, , and hence
Now by the positivity of the essential formula , we obtain
where the last inequality is by Lemma 5.3. Hence we obtain the desired upper bound for . ∎
With the same assumption as in Theorem 5.1, and for all satisfying
By Theorem 5.1, it is sufficient to consider the term
on the right hand side of the upper bound for in Theorem 5.1. Because is bounded and does not depend on , the statement follows. ∎
When either for some , or in Theorem 5.1, we obtain the following guarantee that the average regret of AdamX converges.
With the same assumption as in Theorem 5.1, and either for some , or , AdamX achieves the following guarantee:
By Corollary 5.5, it is sufficient to consider the term
When for some , we have
where the first inequality is from the property that , and the last inequality is from Lemma 2.4. When , we obtain
where the last inequality is from Lemma 2.6. Now, by combining (5) and (5) with Corollary 5.5, we obtain the desired result. ∎
Experiments
While we consider our main contributions as the theoretical analyses on AMSGrad and AdamX in the previous sections, we provide experimental results in this section for AMSGrad and AdamX. Concretely, we use the PyTorch code for AMSGradhttps://pytorch.org/docs/stable/_modules/torch/optim/adam.html via setting the boolean flag amsgrad = True. The code for AdamX is based on that of AMSGrad, with corresponding modifications as in Algorithm 2. The parameters for AMSGrad and AdamX are identical in our experiments, namely , the term added to the denominator to improve numerical stability is , and and additionally we set with to make use of Corollary 5.6 on the convergence of AdamX.
The learning rate is scheduled for both optimizers AMSGrad and AdamX as follows: , , , , if the epoch is correspondingly in the ranges , , $32\times 32$) as the dataset and the residual networks ResNet18 and PreActResNet18 for training with batch size is 128. The testing result is given in Figure 1 where one can see that AMSGrad and AdamX behaves similarly, which supports our theoretical results on the convergence of both AMSGrad (Section 4) and AdamX (Section 5).
Conclusion
We have shown that the convergence proof of AMSGrad is problematic, and presented various fixes for it, which include a new and slightly modified version called AdamX. Along the lines, we also observe that the issue has been neglected in various works such as in [2, Theorem 10.5], [5, Theorem 4], [6, Theorem 4.4], [7, Theorem 4.2]. Our work helps ensure the theoretical foundation of those optimizers.