Gradient descent: Difference between revisions

Content deleted Content added
m ndash
mNo edit summary
Line 37:
This process is illustrated in the adjacent picture. Here, <math>f</math> is assumed to be defined on the plane, and that its graph has a [[Bowl (vessel)|bowl]] shape. The blue curves are the [[contour line]]s, that is, the regions on which the value of <math>f</math> is constant. A red arrow originating at a point shows the direction of the negative gradient at that point. Note that the (negative) gradient at a point is [[orthogonal]] to the contour line going through that point. We see that gradient ''descent'' leads us to the bottom of the bowl, that is, to the point where the value of the function <math>f</math> is minimal.
 
=== An analogy for understanding gradient descent ===
[[File:Okanogan-Wenatchee National Forest, morning fog shrouds trees (37171636495).jpg|thumb|Fog in the mountains]]
The basic intuition behind gradient descent can be illustrated by a hypothetical scenario. People are stuck in the mountains and are trying to get down (i.e., trying to find the global minimum). There is heavy fog such that visibility is extremely low. Therefore, the path down the mountain is not visible, so they must use local information to find the minimum. They can use the method of gradient descent, which involves looking at the steepness of the hill at their current position, then proceeding in the direction with the steepest descent (i.e., downhill). If they were trying to find the top of the mountain (i.e., the maximum), then they would proceed in the direction of steepest ascent (i.e., uphill). Using this method, they would eventually find their way down the mountain or possibly get stuck in some hole (i.e., local minimum or [[saddle point]]), like a mountain lake. However, assume also that the steepness of the hill is not immediately obvious with simple observation, but rather it requires a sophisticated instrument to measure, which the persons happen to have at the moment. It takes quite some time to measure the steepness of the hill with the instrument, thus they should minimize their use of the instrument if they wanted to get down the mountain before sunset. The difficulty then is choosing the frequency at which they should measure the steepness of the hill so not to go off track.
Line 121:
</math>
 
characteristicBecause zigeach step is taken in the steepest direction, steepest-zagdescent steps alternate between directions aligned with the extreme axes of the elongated level sets. When <math>\kappa(\mathbf{A})</math> is large, this produces a characteristic zig–zag path. The poor conditioning of <math> \mathbf{A} </math> is the primary cause of the slow convergence, and orthogonality of successive residuals reinforces this alternation.
Because each step is taken in the steepest direction, steepest-descent steps
alternate between directions aligned with the extreme axes of the elongated
level sets. When <math>\kappa(\mathbf{A})</math> is large, this produces a
characteristic zig-zag path. The poor conditioning of <math> \mathbf{A} </math> is the primary cause of the slow convergence, and orthogonality of successive residuals reinforces this alternation.
 
[[File:Steepest descent convergence path for A = 2 2, 2 3.png|thumb|Convergence path of steepest descent method for A = [[2, 2], [2, 3]]]]
Line 236 ⟶ 233:
The gradient descent can take many iterations to compute a local minimum with a required [[accuracy]], if the [[curvature]] in different directions is very different for the given function. For such functions, [[preconditioning]], which changes the geometry of the space to shape the function level sets like [[concentric circles]], cures the slow convergence. Constructing and applying preconditioning can be computationally expensive, however.
 
The gradient descent can be modified via momentums<ref>{{Cite journal |last1=Abdulkadirov |first1=Ruslan |last2=Lyakhov |first2=Pavel |last3=Nagornov |first3=Nikolay |date=January 2023 |title=Survey of Optimization Algorithms in Modern Neural Networks |journal=Mathematics |language=en |volume=11 |issue=11 |pages=2466 |doi=10.3390/math11112466 |doi-access=free |issn=2227-7390}}</ref> ([[Nesterov]], Polyak,<ref>{{Cite journal |last1=Diakonikolas |first1=Jelena |last2=Jordan |first2=Michael I. |date=January 2021 |title=Generalized Momentum-Based Methods: A Hamiltonian Perspective |url=https://epubs.siam.org/doi/10.1137/20M1322716 |journal=SIAM Journal on Optimization |language=en |volume=31 |issue=1 |pages=915–944 |doi=10.1137/20M1322716 |arxiv=1906.00436 |issn=1052-6234}}</ref> and Frank-WolfeFrank–Wolfe<ref>{{Cite journal |last=Meyer |first=Gerard G. L. |date=November 1974 |title=Accelerated Frank–Wolfe Algorithms |url=http://epubs.siam.org/doi/10.1137/0312050 |journal=SIAM Journal on Control |language=en |volume=12 |issue=4 |pages=655–663 |doi=10.1137/0312050 |issn=0036-1402|url-access=subscription }}</ref>) and heavy-ball parameters (exponential moving averages<ref>{{Citation |last1=Kingma |first1=Diederik P. |title=Adam: A Method for Stochastic Optimization |date=2017-01-29 |last2=Ba |first2=Jimmy|arxiv=1412.6980 }}</ref> and positive-negative momentum<ref>{{Cite journal |last1=Xie |first1=Zeke |last2=Yuan |first2=Li |last3=Zhu |first3=Zhanxing |last4=Sugiyama |first4=Masashi |date=2021-07-01 |title=Positive-Negative Momentum: Manipulating Stochastic Gradient Noise to Improve Generalization |url=https://proceedings.mlr.press/v139/xie21h.html |journal=Proceedings of the 38th International Conference on Machine Learning |language=en |publisher=PMLR |pages=11448–11458|arxiv=2103.17182 }}</ref>). The main examples of such optimizers are Adam, DiffGrad, Yogi, AdaBelief, etc.
 
Methods based on [[Newton's method in optimization|Newton's method]] and inversion of the [[Hessian matrix|Hessian]] using [[conjugate gradient]] techniques can be better alternatives.<ref>{{cite book |first1=W. H. |last1=Press |author-link1 = William H. Press |first2=S. A. |last2=Teukolsky |author-link2 = Saul Teukolsky |first3=W. T. |last3=Vetterling |first4=B. P. |last4=Flannery |author-link4 = Brian P. Flannery |title=Numerical Recipes in C: The Art of Scientific Computing |url=https://archive.org/details/numericalrecipes00pres_0 |url-access=registration |edition=2nd |publisher=[[Cambridge University Press]] |___location=New York |year=1992 |isbn=0-521-43108-5 }}</ref><ref>{{cite book |first=T. |last=Strutz |title=Data Fitting and Uncertainty: A Practical Introduction to Weighted Least Squares and Beyond |edition=2nd |publisher=Springer Vieweg |year=2016 |isbn=978-3-658-11455-8 }}</ref> Generally, such methods converge in fewer iterations, but the cost of each iteration is higher. An example is the [[Broyden–Fletcher–Goldfarb–Shanno algorithm|BFGS method]] which consists in calculating on every step a matrix by which the gradient vector is multiplied to go into a "better" direction, combined with a more sophisticated [[line search]] algorithm, to find the "best" value of <math>\eta.</math> For extremely large problems, where the computer-memory issues dominate, a limited-memory method such as [[Limited-memory BFGS|L-BFGS]] should be used instead of BFGS or the steepest descent.
Line 246 ⟶ 243:
 
==Modifications==
Gradient descent can converge to a local minimum and slow down in a neighborhood of a [[saddle point]]. Even for unconstrained quadratic minimization, gradient descent develops a zig-zagzig–zag pattern of subsequent iterates as iterations progress, resulting in slow convergence. Multiple modifications of gradient descent have been proposed to address these deficiencies.
 
===Fast gradient methods===
Line 259 ⟶ 256:
 
==Extensions==
Gradient descent can be extended to handle [[Constraint (mathematics)|constraints]] by including a [[Projection (linear algebra)|projection]] onto the set of constraints. This method is only feasible when the projection is efficiently computable on a computer. Under suitable assumptions, this method converges. This method is a specific case of the [[Forward–backward algorithm|forward-backwardforward–backward algorithm]] for monotone inclusions (which includes [[convex programming]] and [[Variational inequality|variational inequalities]]).<ref>{{cite book |first1=P. L. |last1=Combettes |first2=J.-C. |last2=Pesquet |arxiv=0912.3522 |chapter=Proximal splitting methods in signal processing |title=Fixed-Point Algorithms for Inverse Problems in Science and Engineering |editor1-first=H. H. |editor1-last=Bauschke |editor2-link=Regina S. Burachik |editor2-first=R. S. |editor2-last=Burachik |editor3-first=P. L. |editor3-last=Combettes |editor4-first=V. |editor4-last=Elser |editor5-first=D. R. |editor5-last=Luke |editor6-first=H. |editor6-last=Wolkowicz |pages=185–212 |publisher=Springer |___location=New York |year=2011 |isbn=978-1-4419-9568-1 }}</ref>
 
Gradient descent is a special case of [[mirror descent]] using the squared Euclidean distance as the given [[Bregman divergence]].<ref>{{cite web | url=https://tlienart.github.io/posts/2018/10/27-mirror-descent-algorithm/ | title=Mirror descent algorithm }}</ref>
Line 288 ⟶ 285:
{{Reflist|30em}}
 
== Further reading ==
*{{cite book |first1=Stephen |last1=Boyd |author-link=Stephen P. Boyd |first2=Lieven |last2=Vandenberghe |chapter=Unconstrained Minimization |title=Convex Optimization |___location=New York |publisher=Cambridge University Press |year=2004 |isbn=0-521-83378-7 |chapter-url=https://web.stanford.edu/~boyd/cvxbook/bv_cvxbook.pdf#page=471 |pages=457–520 }}
*{{cite book |first1=Edwin K. P. |last1=Chong |first2=Stanislaw H. |last2=Żak |chapter=Gradient Methods |title=An Introduction to Optimization |edition=Fourth |___location=Hoboken |publisher=Wiley |year=2013 |isbn=978-1-118-27901-4 |pages=131–160 |chapter-url=https://books.google.com/books?id=iD5s0iKXHP8C&pg=PA131 }}
*{{cite book |first=David M. |last=Himmelblau |title=Applied Nonlinear Programming |___location=New York |publisher=McGraw-Hill |year=1972 |isbn=0-07-028921-2 |chapter=Unconstrained Minimization Procedures Using Derivatives |pages=63–132 }}
 
== External links ==
{{Commons category|Gradient descent}}
* [httphttps://codingplayground.blogspot.it/2013/05/learning-linear-regression-with.html Using gradient descent in C++, Boost, Ublas for linear regression]
* [https://www.khanacademy.org/math/multivariable-calculus/multivariable-derivatives/gradient-and-directional-derivatives/v/gradient Series of Khan Academy videos discusses gradient ascent]
* [http://neuralnetworksanddeeplearning.com/chap1.html#learning_with_gradient_descent Online book teaching gradient descent in deep neural network context]