我们从梯度下降开始。该算法有许多优点,但速度不是其中之一。它很简单——当优化一个光滑函数 f 时,我们在梯度方向上迈出一小步 wk+1=wk−α∇f(wk). 对于足够小的步长,梯度下降在每次迭代中都会单调改进。它总是能收敛,尽管是到一个局部最小值。在一些较弱的曲率条件下,它甚至可以以指数速率到达那里。
为了理解我们能做什么的极限,我们首先必须正式定义我们正在搜索的算法空间。以下是一种可能的定义。我们将观察到,梯度下降和动量都可以被"展开"。实际上,由于 w1w2wk+1===⋮=w0−α∇f(w0)w1−α∇f(w1)w0−α∇f(w0)−α∇f(w1)w0−α∇f(w0)−⋯⋯−α∇f(wk) 我们可以将梯度下降写为 wk+1=w0−αi∑k∇f(wi). 类似的技巧可以用于动量:wk+1=w0+αi∑k1−β(1−βk+1−i)∇f(wi). 实际上,各种一阶算法,包括共轭梯度算法、AdaMax、平均梯度等,都可以写成(虽然不那么整洁)这种展开形式。因此满足 wk+1=w0+i∑kγik∇f(wi) for some γik 的算法类包含动量、梯度下降以及你可能想到的一大堆其他算法。这就是 Nesterov 的假设 2.1.4 [5] 中假设的内容。但让我们更进一步,扩展这个类以允许对不同方向使用不同步长。wk+1=w0+i∑kΓik∇f(wi) for some diagonal matrix Γik. 这类方法涵盖了训练神经网络的大多数流行算法,包括 ADAM 和 AdaGrad。我们将这类方法称为"线性一阶方法",并且我们将展示所有这些方法最终都会在一个函数上失败。
我深深感谢 Shan Carter 和 Chris Olah 的编辑贡献,没有他们,本文将会大为逊色。Shan Carter 对我许多原创交互组件进行了彻底重新设计,为所有图形带来了视觉一致性,并对页面性能进行了宝贵的优化。Chris Olah 在所有细节和抽象层面都提供了无可挑剔的编辑反馈——从内容结构到公式对齐。
我也感谢 Michael Nielsen 提供了本文的标题,它真正使文章融为一体。Marcos Ginestra 为本文最早期的草稿提供了编辑意见,以及在我最需要时的精神鼓励。我还要感谢我的审稿人 Matt Hoffman 和匿名审稿人 B,感谢他们敏锐的观察和批评。我特别要感谢审稿人 B,他指出原稿中的两个非平凡错误(讨论 here)。首图的等高线绘制库是 Ben Frederickson、Jeff Heer 和 Mike Bostock 的共同作品。
非常感谢在 github 上提交的诸多 pull request 和 issue。特别感谢 Osemwaro Pedro 发现了其中一个公式中的 off-by-one 错误。也感谢 Dan Schmidt 对整个项目进行了编辑,纠正了大量排版和语法错误。
It is possible, however, to construct very specific counterexamples where momentum does not converge, even on convex functions. See [4] for a counterexample.
In Tikhonov Regression we add a quadratic penalty to the regression, minimizing
minimize21∥Zw−d∥2+2η∥w∥2=21wT(ZTZ+ηI)w−(Zd)Tw
Recall that ZTZ=Qdiag(Λ1,…,Λn)QT. The solution to Tikhonov Regression is therefore
(ZTZ+ηI)−1(Zd)=Qdiag(λ1+η1,⋯,λn+η1)QT(Zd)
We can think of regularization as a function which decays the largest eigenvalues, as follows:
Tikhonov Regularized λi=λi+η1=λi1(1−(1+λi/η)−1).
Gradient descent can be seen as employing a similar decay, but with the decay rate
Gradient Descent Regularized λi=λi1(1−(1−αλi)k)
instead. Note that this decay is dependent on the step-size.
This is true as we can write updates in matrix form as
(1α01)(yik+1xik+1)=(β0λi1)(yikxik)
which implies, by inverting the matrix on the left,
(yik+1xik+1)=(β−αβλi1−αλi)(yikxik)=Rk+1(xi0yi0)
We can write out the convergence rates explicitly. The eigenvalues are
σ1σ2=21(1−αλ+β+√(−αλ+β+1)2−4β)=21(1−αλ+β−√(−αλ+β+1)2−4β)
When the (−αλ+β+1)2−4β<0 is less than zero,
then the roots are complex and the convergence rate is
∣σ1∣=∣σ2∣=√(1−αλ+β)2+∣(−αλ+β+1)2−4β∣=2√β
Which is, surprisingly, independent of the step-size or the eigenvalue αλ. When the roots are real, the convergence rate is
max{∣σ1∣,∣σ2∣}=21max{∣1−αλi+β±√(1−αλi+β)2−4β∣}
This can be derived by reducing the inequalities for all 4 + 1 cases in the explicit form of the convergence rate above.
We must optimize over
α,βminmax{∥∥∥∥(β−αβλi1−αλi)∥∥∥∥,…,∥∥∥∥(β−αβλn1−αλn)∥∥∥∥}.
(∥⋅∥ here denotes the magnitude of the maximum eigenvalue), and occurs when the roots of the characteristic polynomial are repeated for the matrices corresponding to the extremal eigenvalues.
The above optimization problem is bounded from below by 0, and vector of all 1’s achieve this.
This can be written explicitly as
[LG]ij=⎩⎪⎨⎪⎧degree of vertex i−10i=ji≠j,(i,j) or (j,i)∈Eotherwise
We use the infinity norm to measure our error, similar results can be derived for the 1 and 2 norms.
The momentum iterations are
zk+1wk+1=βzk+Awk+error(wk)=wk−αzk+1.
which, after a change of variables, become
(1α01)(yik+1xik+1)=(β0λi1)(yikxik)+(ϵik0)
Inverting the 2×2 matrix on the left, and applying the formula recursively yields the final solution.
On the 1D function f(x)=2λx2, the objective value is
Ef(xk)=2λE[(xk)2]=2λE(e2TRk(y0x0)+ϵke2Ti=1∑kRk−i(1−α))2=2λe2TRk(y0x0)+2λE(ϵke2Ti=1∑kRk−i(1−α))2=2λe2TRk(y0x0)+2λE[ϵk]⋅i=1∑k(e2TRk−i(1−α))2=2λe2TRk(y0x0)+2λE[ϵk⋅i=1∑kγi2,γi=e2TRk−i(1−α)
The third inequality uses the fact that Eϵk=0 and the fourth uses the fact they are uncorrelated.
参考文献
On the importance of initialization and momentum in deep learning.[PDF] Sutskever, I., Martens, J., Dahl, G.E. and Hinton, G.E., 2013. ICML (3), Vol 28, pp. 1139—1147.
Some methods of speeding up the convergence of iteration methods[PDF] Polyak, B.T., 1964. USSR Computational Mathematics and Mathematical Physics, Vol 4(5), pp. 1—17. Elsevier. DOI: 10.1016/0041-5553(64)90137-5
Theory of gradient methods Rutishauser, H., 1959. Refined iterative methods for computation of the solution and the eigenvalues of self-adjoint boundary value problems, pp. 24—49. Springer. DOI: 10.1007/978-3-0348-7224-9_2
Analysis and design of optimization algorithms via integral quadratic constraints[PDF] Lessard, L., Recht, B. and Packard, A., 2016. SIAM Journal on Optimization, Vol 26(1), pp. 57—95. SIAM.
Introductory lectures on convex optimization: A basic course Nesterov, Y., 2013. , Vol 87. Springer Science \& Business Media. DOI: 10.1007/978-1-4419-8853-9
Natural gradient works efficiently in learning[link] Amari, S., 1998. Neural computation, Vol 10(2), pp. 251—276. MIT Press. DOI: 10.1162/089976698300017746
Deep Learning, NIPS′2015 Tutorial[PDF] Hinton, G., Bengio, Y. and LeCun, Y., 2015.
Adaptive restart for accelerated gradient schemes[PDF] O’Donoghue, B. and Candes, E., 2015. Foundations of computational mathematics, Vol 15(3), pp. 715—732. Springer. DOI: 10.1007/s10208-013-9150-3
The Nth Power of a 2x2 Matrix.[PDF] Williams, K., 1992. Mathematics Magazine, Vol 65(5), pp. 336. MAA. DOI: 10.2307/2691246
From Averaging to Acceleration, There is Only a Step-size.[PDF] Flammarion, N. and Bach, F.R., 2015. COLT, pp. 658—695.
On the momentum term in gradient descent learning algorithms[PDF] Qian, N., 1999. Neural networks, Vol 12(1), pp. 145—151. Elsevier. DOI: 10.1016/s0893-6080(98)00116-6
Understanding deep learning requires rethinking generalization[PDF] Zhang, C., Bengio, S., Hardt, M., Recht, B. and Vinyals, O., 2016. arXiv preprint arXiv:1611.03530.
A differential equation for modeling Nesterov’s accelerated gradient method: Theory and insights[PDF] Su, W., Boyd, S. and Candes, E., 2014. Advances in Neural Information Processing Systems, pp. 2510—2518.
The Zen of Gradient Descent[HTML] Hardt, M., 2013.
A geometric alternative to Nesterov’s accelerated gradient descent[PDF] Bubeck, S., Lee, Y.T. and Singh, M., 2015. arXiv preprint arXiv:1506.08187.
An optimal first order method based on optimal quadratic averaging[PDF] Drusvyatskiy, D., Fazel, M. and Roy, S., 2016. arXiv preprint arXiv:1604.06543.
Linear coupling: An ultimate unification of gradient and mirror descent[PDF] Allen-Zhu, Z. and Orecchia, L., 2014. arXiv preprint arXiv:1407.1537.
Accelerating the cubic regularization of Newton’s method on convex problems[PDF] Nesterov, Y., 2008. Mathematical Programming, Vol 112(1), pp. 159—181. Springer. DOI: 10.1007/s10107-006-0089-x
@article{goh2017why,
author = {Goh, Gabriel},
title = {Why Momentum Really Works},
journal = {Distill},
year = {2017},
url = {http://distill.pub/2017/momentum},
doi = {10.23915/distill.00006}
}
On the importance of initialization and momentum in deep learning.[PDF] I. Sutskever, J. Martens, G.E. Dahl, G.E. Hinton. ICML (3), Vol 28, pp. 1139—1147. 2013.
Some methods of speeding up the convergence of iteration methods[PDF] B.T. Polyak. USSR Computational Mathematics and Mathematical Physics, Vol 4(5), pp. 1—17. Elsevier. 1964. DOI: 10.1016/0041-5553(64)90137-5
Theory of gradient methods H. Rutishauser. Refined iterative methods for computation of the solution and the eigenvalues of self-adjoint boundary value problems, pp. 24—49. Springer. 1959. DOI: 10.1007/978-3-0348-7224-9_2
Analysis and design of optimization algorithms via integral quadratic constraints[PDF] L. Lessard, B. Recht, A. Packard. SIAM Journal on Optimization, Vol 26(1), pp. 57—95. SIAM. 2016.
Introductory lectures on convex optimization: A basic course Y. Nesterov. , Vol 87. Springer Science \& Business Media. 2013. DOI: 10.1007/978-1-4419-8853-9
Natural gradient works efficiently in learning[link] S. Amari. Neural computation, Vol 10(2), pp. 251—276. MIT Press. 1998. DOI: 10.1162/089976698300017746
Deep Learning, NIPS′2015 Tutorial[PDF] G. Hinton, Y. Bengio, Y. LeCun. 2015.
Adaptive restart for accelerated gradient schemes[PDF] B. O’Donoghue, E. Candes. Foundations of computational mathematics, Vol 15(3), pp. 715—732. Springer. 2015. DOI: 10.1007/s10208-013-9150-3
The Nth Power of a 2x2 Matrix.[PDF] K. Williams. Mathematics Magazine, Vol 65(5), pp. 336. MAA. 1992. DOI: 10.2307/2691246
From Averaging to Acceleration, There is Only a Step-size.[PDF] N. Flammarion, F.R. Bach. COLT, pp. 658—695. 2015.
On the momentum term in gradient descent learning algorithms[PDF] N. Qian. Neural networks, Vol 12(1), pp. 145—151. Elsevier. 1999. DOI: 10.1016/s0893-6080(98)00116-6
Introductory lectures on convex optimization: A basic course Y. Nesterov. , Vol 87. Springer Science \& Business Media. 2013. DOI: 10.1007/978-1-4419-8853-9
From Averaging to Acceleration, There is Only a Step-size.[PDF] N. Flammarion, F.R. Bach. COLT, pp. 658—695. 2015.
On the importance of initialization and momentum in deep learning.[PDF] I. Sutskever, J. Martens, G.E. Dahl, G.E. Hinton. ICML (3), Vol 28, pp. 1139—1147. 2013.
On the importance of initialization and momentum in deep learning.[PDF] I. Sutskever, J. Martens, G.E. Dahl, G.E. Hinton. ICML (3), Vol 28, pp. 1139—1147. 2013.
Understanding deep learning requires rethinking generalization[PDF] C. Zhang, S. Bengio, M. Hardt, B. Recht, O. Vinyals. arXiv preprint arXiv:1611.03530. 2016.
A differential equation for modeling Nesterov’s accelerated gradient method: Theory and insights[PDF] W. Su, S. Boyd, E. Candes. Advances in Neural Information Processing Systems, pp. 2510—2518. 2014.
Theory of gradient methods H. Rutishauser. Refined iterative methods for computation of the solution and the eigenvalues of self-adjoint boundary value problems, pp. 24—49. Springer. 1959. DOI: 10.1007/978-3-0348-7224-9_2
A geometric alternative to Nesterov’s accelerated gradient descent[PDF] S. Bubeck, Y.T. Lee, M. Singh. arXiv preprint arXiv:1506.08187. 2015.
An optimal first order method based on optimal quadratic averaging[PDF] D. Drusvyatskiy, M. Fazel, S. Roy. arXiv preprint arXiv:1604.06543. 2016.
Linear coupling: An ultimate unification of gradient and mirror descent[PDF] Z. Allen-Zhu, L. Orecchia. arXiv preprint arXiv:1407.1537. 2014.
Accelerating the cubic regularization of Newton’s method on convex problems[PDF] Y. Nesterov. Mathematical Programming, Vol 112(1), pp. 159—181. Springer. 2008. DOI: 10.1007/s10107-006-0089-x
It is possible, however, to construct very specific counterexamples where momentum does not converge, even on convex functions. See [4] for a counterexample.
In Tikhonov Regression we add a quadratic penalty to the regression, minimizing
minimize21∥Zw−d∥2+2η∥w∥2=21wT(ZTZ+ηI)w−(Zd)Tw
Recall that ZTZ=Qdiag(Λ1,…,Λn)QT. The solution to Tikhonov Regression is therefore
(ZTZ+ηI)−1(Zd)=Qdiag(λ1+η1,⋯,λn+η1)QT(Zd)
We can think of regularization as a function which decays the largest eigenvalues, as follows:
Tikhonov Regularized λi=λi+η1=λi1(1−(1+λi/η)−1).
Gradient descent can be seen as employing a similar decay, but with the decay rate
Gradient Descent Regularized λi=λi1(1−(1−αλi)k)
instead. Note that this decay is dependent on the step-size.
This is true as we can write updates in matrix form as
(1α01)(yik+1xik+1)=(β0λi1)(yikxik)
which implies, by inverting the matrix on the left,
(yik+1xik+1)=(β−αβλi1−αλi)(yikxik)=Rk+1(xi0yi0)
We can write out the convergence rates explicitly. The eigenvalues are
σ1σ2=21(1−αλ+β+√(−αλ+β+1)2−4β)=21(1−αλ+β−√(−αλ+β+1)2−4β)
When the (−αλ+β+1)2−4β<0 is less than zero,
then the roots are complex and the convergence rate is
∣σ1∣=∣σ2∣=√(1−αλ+β)2+∣(−αλ+β+1)2−4β∣=2√β
Which is, surprisingly, independent of the step-size or the eigenvalue αλ. When the roots are real, the convergence rate is
max{∣σ1∣,∣σ2∣}=21max{∣1−αλi+β±√(1−αλi+β)2−4β∣}
This can be derived by reducing the inequalities for all 4 + 1 cases in the explicit form of the convergence rate above.
We must optimize over
α,βminmax{∥∥∥∥(β−αβλi1−αλi)∥∥∥∥,…,∥∥∥∥(β−αβλn1−αλn)∥∥∥∥}.
(∥⋅∥ here denotes the magnitude of the maximum eigenvalue), and occurs when the roots of the characteristic polynomial are repeated for the matrices corresponding to the extremal eigenvalues.
The above optimization problem is bounded from below by 0, and vector of all 1’s achieve this.
This can be written explicitly as
[LG]ij=⎩⎪⎨⎪⎧degree of vertex i−10i=ji≠j,(i,j) or (j,i)∈Eotherwise
We use the infinity norm to measure our error, similar results can be derived for the 1 and 2 norms.
The momentum iterations are
zk+1wk+1=βzk+Awk+error(wk)=wk−αzk+1.
which, after a change of variables, become
(1α01)(yik+1xik+1)=(β0λi1)(yikxik)+(ϵik0)
Inverting the 2×2 matrix on the left, and applying the formula recursively yields the final solution.
On the 1D function f(x)=2λx2, the objective value is
Ef(xk)=2λE[(xk)2]=2λE(e2TRk(y0x0)+ϵke2Ti=1∑kRk−i(1−α))2=2λe2TRk(y0x0)+2λE(ϵke2Ti=1∑kRk−i(1−α))2=2λe2TRk(y0x0)+2λE[ϵk]⋅i=1∑k(e2TRk−i(1−α))2=2λe2TRk(y0x0)+2λE[ϵk⋅i=1∑kγi2,γi=e2TRk−i(1−α)
The third inequality uses the fact that Eϵk=0 and the fourth uses the fact they are uncorrelated.