Skip to text

2 The example

To show that the ADAM algorithm may fail to converge on nonconvex functions with Lipschitz gradient, we will exhibit an example in dimension one, which we construct in two stages. We first define sequences of iterates, together with associated function and gradient values, which remain constant throughout the iterations. We next verify that these sequences may be considered as generated by applying the ADAM algorithm to a nonconvex objective function with Lipschitz gradient. (Since the example is unidimensional, we omit the component indices (i) if what follows.) For k≥0, let the sequence of function values and gradients be defined by

(13.5)fk=0andgk=−1,

and the sequence of (potential) iterates be defined (from (13.2)–(13.4)) by x0=0 and

(13.6)mk=β1mk−1+(1−β1)gk=−1,
(13.7)vk=β2vk−1+(1−β2)gk2=1,
(13.8)xk+1=xk−αmkvk=xk+α,

for k≥1, where we used (13.5) to derive the last equality in (13.6) and (13.7). Thus,

(13.9)sk=xk+1−xk=α,

for k≥0 and xk=αk tends to infinity. We now show that there exists a (nonconvex) univariate function f1 defined on R+ with Lipschitz continuous gradient such that fk=f1(xk)=0 and gk=∇x1f1(xk)=−1 for all k≥0. Indeed, a simple Hermite interpolation calculation based of these conditions yields that, for all t∈[αk,α(k+1)],

(13.10)f1(t)=−(t−αk)+3α(t−αk)2−2α2(t−αk)3.

We may then define

f(t)=f1(t)ift≥0,−tift<0,

so that f(t) is well-defined on the whole of R has Lipschitz continuous gradient and is such that the ADAM algorithm (13.6)–(13.8) applied on f starting from x0=0 generates iterates with |gk|=1 for all k≥0. We thus conclude that the ADAM algorithm fails to converge on this particular instance of problem (13.1). A graph of f(t) for t∈[−1,10], α=1 is shown in Figure 13.1. One also verifies that the Lipschitz constant on the interval [xk,xk+1] is given by

L=maxk≥0supt∈[αk,α(k+1)]|∇t2f(t)|=6α.

Moreover, defining Tk(s)=fk+gks, it results from (13.5), [1, Theorem A.9.2], (13.9) and the inequalities

|fk+1−Tk(sk)|=sk≤1αsk2and|gk+1−∇s1Tk(s)|=|−1+1|≤1αsk

that f(t) is bounded below by a constant only depending on α. As a consequence, we see that, for any fixed (β1,β2)∈[0,1)2 and α>0, there exist unidimensional functions with Lipschitz continuous gradient whose gradient’s Lipschitz constant is as small as 6/α, which is bounded below by a constant only depending on α and for which the ADAM algorithm (13.6)–(13.8) starting from x0=0 generates iterates tending to infinity with constant nonzero gradients (therefore failing to converge).

Figure 13.1 The shape of f(t) for small values of |t|.

Since our example is unidimensional and since ADAM is defined componentwise, the same conclusion obviously applies irrespective of n, the problem dimension. Indeed divergence in a single component implies divergence on the whole space.

Our result thus extends that of [5] in that it includes methods for arbitrary (β1,β2)∈(0,1)2 but fixed stepsize. Note that |∇t1f(t)| is bounded by L for all t∈R, again at variance with the example of this reference.

Observe that our conclusions would also hold if we had fixed gk to another negative constant (we can multiply f by this constant) or if, instead of (13.4), we had considered

[xk+1]i=[xk]i−αk[mk]iϵ+[vk]i2,or[xk+1]i=[xk]i−αk[mk]iϵ+[vk]i2,

where ϵ is a small positive constant and the (now iteration-dependent) stepsizes αk are bounded away from zero, but they do not apply in the more realistic situation where stepsizes αk→0 are used (as is for instance the case in [5, Proposition 1.1], where αk is a multiple of 1/k). We also remark that, because of the periodicity of our example, it would be possible to derive a trigonometric variant. We finally note that we have chosen a constant zero value for fk in order to simplify our bounds, but that it is also possible to choose fk+1>fk (leading to an monotonically increasing sequence of function values) without qualitatively affecting our conclusion, although this leads to a larger value of L.

Bibliography

[1]C. Cartis, N. I. M. Gould, and Ph. L. Toint. Evaluation Complexity of Algorithms for Nonconvex Optimization. MOS-SIAM Series on Optimization, volume 30. SIAM, Philadelphia, USA, June 2022. →

[2]A. Défossez, L. Bottou, F. Bach, and N. Usunier. A simple convergence proof for Adam and Adagrad. Transactions on Machine Learning Research, October 2022. →

[3]D. Kingma and J. Ba. Adam. A method for stochastic optimization. In: Proceedings in the International Conference on Learning Representations (ICLR), 2015. →

[4]S. Reddi, S. Kale, and S. Kumar. On the convergence of Adam and beyond. In: Proceedings in the International Conference on Learning Representations (ICLR), 2018. a, b

[5]Y. Zhang, C. Chen, N. Shi, R. Sun, and Z.-Q. Luo. Adam can converge without any modification on update rules. arXiv:2208.09632v5, 2022. a, b, c, d