Product Code Database
Example Keywords: grand theft -kindle $63-118
   » » Wiki: Gradient Descent
Tag Wiki 'Gradient Descent'.
Tag

Gradient descent is a method for unconstrained mathematical optimization. It is a iterative for minimizing a differentiable multivariate function.

The idea is to take repeated steps in the opposite direction of the (or approximate gradient) of the function at the current point, because this is the direction of steepest descent. Conversely, stepping in the direction of the gradient will lead to a trajectory that maximizes that function; the procedure is then known as gradient ascent. It is particularly useful in machine learning for minimizing the cost or loss function.

(2004). 9780521833783, Cambridge University Press. .
Gradient descent should not be confused with local search algorithms, although both are for optimization.

Gradient descent is generally attributed to Augustin-Louis Cauchy, who first suggested it in 1847.

(2012). 9783936609585, EMS Press.
independently proposed a similar method in 1907. Its convergence properties for non-linear optimization problems were first studied by in 1944, with the method becoming increasingly well-studied and used in the following decades.

A simple extension of gradient descent, stochastic gradient descent, serves as the most basic algorithm used for training most deep networks today.


Description
Gradient descent is based on the observation that if the multi-variable function f(\mathbf{x}) is defined and differentiable in a neighborhood of a point \mathbf{a}, then f(\mathbf{x}) decreases fastest if one goes from \mathbf{a} in the direction of the negative of f at \mathbf{a}, -\nabla f(\mathbf{a}). It follows that, if

\mathbf{a}_{n+1} = \mathbf{a}_n-\eta \nabla f(\mathbf{a}_n)

for a small enough step size or \eta\in \R_{+}, then f(\mathbf{a_n})\geq f(\mathbf{a_{n+1}}). In other words, the term \eta\nabla f(\mathbf{a}) is subtracted from \mathbf{a} because we want to move against the gradient, toward the local minimum. With this observation in mind, one starts with a guess \mathbf{x}_0 for a local minimum of f, and considers the sequence \mathbf{x}_0, \mathbf{x}_1, \mathbf{x}_2, \ldots such that

\mathbf{x}_{n+1}=\mathbf{x}_n-\eta_n\nabla f(\mathbf{x}_n),\ n \ge 0.

We have a monotonic sequence

f(\mathbf{x}_0)\ge f(\mathbf{x}_1)\ge f(\mathbf{x}_2)\ge \cdots,

so the sequence (\mathbf{x}_n) converges to the desired local minimum. Note that the value of the step size \eta is allowed to change at every iteration.

It is possible to guarantee the convergence to a local minimum under certain assumptions on the function f (for example, f and \nabla f Lipschitz) and particular choices of \eta. Those include the sequence

\eta_{n} = \frac{ \left | \left (\mathbf x_{n} - \mathbf x_{n-1} \right )^\top \left \nabla \right |}{\left \|\nabla f(\mathbf{x}_{n}) - \nabla f(\mathbf{x}_{n-1}) \right \|^2}

as in the Barzilai-Borwein method,

(2025). 9780387242545, Springer.
or a sequence \eta_n satisfying the (which can be found by using ). When the function f is , all local minima are also global minima, so in this case gradient descent can converge to the global solution.

This process is illustrated in the adjacent picture. Here, f is assumed to be defined on the plane, and that its graph has a bowl shape. The blue curves are the , that is, the regions on which the value of f 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 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 f is minimal.


An analogy for understanding gradient descent
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 ), 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.

In this analogy, the persons represent the algorithm, and the path taken down the mountain represents the sequence of parameter settings that the algorithm will explore. The steepness of the hill represents the of the function at that point. The instrument used to measure steepness is differentiation. The direction they choose to travel in aligns with the of the function at that point. The amount of time they travel before taking another measurement is the step size.


Choosing the step size and descent direction
Since using a step size \eta that is too small would slow convergence, and a \eta too large would lead to overshoot and divergence, finding a good setting of \eta is an important practical problem. Philip Wolfe also advocated using "clever choices of the descent direction" in practice. While using a direction that deviates from the steepest descent direction may seem counter-intuitive, the idea is that the smaller slope may be compensated for by being sustained over a much longer distance.

To reason about this mathematically, consider a direction \mathbf{p}_n and step size \eta_n and consider the more general update:

\mathbf{a}_{n+1} = \mathbf{a}_n-\eta_n\,\mathbf{p}_n.
Finding good settings of \mathbf{p}_n and \eta_n requires some thought. First of all, we would like the update direction to point downhill. Mathematically, letting \theta_n denote the angle between -\nabla f(\mathbf{a_n}) and \mathbf{p}_n, this requires that \cos \theta_n > 0. To say more, we need more information about the objective function that we are optimising. Under the fairly weak assumption that f is continuously differentiable, we may prove that:

This inequality implies that the amount by which we can be sure the function f is decreased depends on a trade off between the two terms in square brackets. The first term in square brackets measures the angle between the descent direction and the negative gradient. The second term measures how quickly the gradient changes along the descent direction.

In principle inequality () could be optimized over \mathbf{p}_n and \eta_n to choose an optimal step size and direction. The problem is that evaluating the second term in square brackets requires evaluating \nabla f(\mathbf{a}_n - t \eta_n \mathbf{p}_n), and extra gradient evaluations are generally expensive and undesirable. Some ways around this problem are:

  • Forgo the benefits of a clever descent direction by setting \mathbf{p}_n = \nabla f(\mathbf{a_n}), and use to find a suitable step-size \gamma_n, such as one that satisfies the . A more economic way of choosing learning rates is backtracking line search, a method that has both good theoretical guarantees and experimental results. Note that one does not need to choose \mathbf{p}_n to be the gradient; any direction that has positive inner product with the gradient will result in a reduction of the function value (for a sufficiently small value of \eta_n).
  • Assuming that f is twice-differentiable, use its Hessian \nabla^2 f to estimate \|\nabla f(\mathbf{a}_n - t \eta_n \mathbf{p}_n) - \nabla f(\mathbf{a}_n)\|_2 \approx \| t \eta_n \nabla^2 f(\mathbf{a}_n) \mathbf{p}_n\|.Then choose \mathbf{p}_n and \eta_n by optimising inequality ().
  • Assuming that \nabla f is Lipschitz, use its Lipschitz constant L to bound \|\nabla f(\mathbf{a}_n - t \eta_n \mathbf{p}_n) - \nabla f(\mathbf{a}_n)\|_2 \leq L t \eta_n \|\mathbf{p}_n\|. Then choose \mathbf{p}_n and \eta_n by optimising inequality ().
  • Build a custom model of \max_{t\in0,1} \frac{\|\nabla f(\mathbf{a}_n - t \eta_n \mathbf{p}_n) - \nabla f(\mathbf{a}_n)\|_2}{\| \nabla f(\mathbf{a}_n) \|_2} for f. Then choose \mathbf{p}_n and \eta_n by optimising inequality ().
  • Under stronger assumptions on the function f such as , more advanced techniques may be possible.

Usually by following one of the recipes above, convergence to a local minimum can be guaranteed. When the function f is , all local minima are also global minima, so in this case gradient descent can converge to the global solution.


Solution of a linear system
Gradient descent can be used to solve a system of linear equations

\mathbf{A}\mathbf{x}-\mathbf{b}=0

reformulated as a quadratic minimization problem. If the system matrix \mathbf{A} is real and positive-definite, an objective function is defined as the quadratic function, with minimization of

f(\mathbf{x})=\mathbf{x}^\top \mathbf{A}\mathbf{x}-2\mathbf{x}^\top \mathbf{b},

so that

\nabla f(\mathbf{x})=2(\mathbf{A}\mathbf{x}-\mathbf{b}).

For a general real matrix \mathbf{A}, linear least squares define

f(\mathbf{x})=\left\|\mathbf{A}\mathbf{x}-\mathbf{b}\right\|^2.

In traditional linear least squares for real \mathbf{A} and \mathbf{b} the is used, in which case

\nabla f(\mathbf{x})=2\mathbf{A}^\top(\mathbf{A}\mathbf{x}-\mathbf{b}).

The minimization, finding the locally optimal step size \eta on every iteration, can be performed analytically for quadratic functions, and explicit formulas for the locally optimal \eta are known.

(2025). 9780898715347, Society for Industrial and Applied Mathematics. .

For example, for real and positive-definite matrix \mathbf{A}, a simple algorithm can be as follows,

\begin{align}
& \text{repeat in the loop:} \\ & \qquad \mathbf{r} := \mathbf{b} - \mathbf{A x} \\ & \qquad \eta := {\mathbf{r}^\top \mathbf{r}}/{\mathbf{r}^\top \mathbf{A r}} \\ & \qquad \mathbf{x} := \mathbf{x} + \eta\mathbf{r} \\ & \qquad \hbox{if } \mathbf{r}^\top \mathbf{r} \text{ is sufficiently small, then exit loop} \\ & \text{end repeat loop} \\ & \text{return } \mathbf{x} \text{ as the result} \end{align}

To avoid multiplying by \mathbf{A} twice per iteration, we note that \mathbf{x} := \mathbf{x} + \eta\mathbf{r} implies \mathbf{r} := \mathbf{r} - \eta\mathbf{A r}, which gives the traditional algorithm,

\begin{align}
& \mathbf{r} := \mathbf{b} - \mathbf{A x} \\ & \text{repeat in the loop:} \\ & \qquad \eta := {\mathbf{r}^\top \mathbf{r}}/{\mathbf{r}^\top \mathbf{A r}} \\ & \qquad \mathbf{x} := \mathbf{x} + \eta\mathbf{r} \\ & \qquad \hbox{if } \mathbf{r}^\top \mathbf{r} \text{ is sufficiently small, then exit loop} \\ & \qquad \mathbf{r} := \mathbf{r} - \eta\mathbf{A r} \\ & \text{end repeat loop} \\ & \text{return } \mathbf{x} \text{ as the result} \end{align}

The method is rarely used for solving linear equations, with the conjugate gradient method being one of the most popular alternatives. The number of gradient descent iterations is commonly proportional to the spectral \kappa(\mathbf{A}) of the system matrix \mathbf{A} (the ratio of the maximum to minimum of , while the convergence of conjugate gradient method is typically determined by a square root of the condition number, i.e., is much faster. Both methods can benefit from , where gradient descent may require less assumptions on the preconditioner.


Geometric behavior and residual orthogonality
In steepest descent applied to solving \mathbf{A x} = \mathbf{b} , where \mathbf{A} is symmetric positive-definite, the residual vectors \mathbf{r}_k = \mathbf{b} - \mathbf{A}\mathbf{x}_k are orthogonal across iterations:

\mathbf{r}_{k+1}^\top \mathbf{r}_k = 0.

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 \kappa(\mathbf{A}) is large, this produces a characteristic zig-zag path. The poor conditioning of \mathbf{A} is the primary cause of the slow convergence, and orthogonality of successive residuals reinforces this alternation.

As shown in the image on the right, steepest descent converges slowly due to the high condition number of \mathbf{A} , and the orthogonality of residuals forces each new direction to undo the overshoot from the previous step. The result is a path that zigzags toward the solution. This inefficiency is one reason conjugate gradient or preconditioning methods are preferred.

(2025). 9783031224294, Springer.


Solution of a non-linear system
Gradient descent can also be used to solve a system of nonlinear equations. Below is an example that shows how to use the gradient descent to solve for three unknown variables, x1, x2, and x3. This example shows one iteration of the gradient descent.

Consider the nonlinear system of equations

\begin{cases}
3x_1-\cos(x_2x_3)-\tfrac{3}{2} =0 \\ 4x_1^2-625x_2^2+2x_2-1 = 0 \\ \exp(-x_1x_2)+20x_3+\tfrac{10\pi-3}{3} =0 \end{cases}

Let us introduce the associated function

G(\mathbf{x}) = \begin{bmatrix}
3x_1-\cos(x_2x_3)-\tfrac{3}{2} \\ 4x_1^2-625x_2^2+2x_2-1 \\ \exp(-x_1x_2)+20x_3+\tfrac{10\pi-3}{3} \\ \end{bmatrix},

where

\mathbf{x} =\begin{bmatrix}
 x_1 \\
 x_2 \\
 x_3 \\
     
\end{bmatrix}.

One might now define the objective function

\begin{align}f(\mathbf{x}) &= \frac{1}{2} G^\top(\mathbf{x}) G(\mathbf{x}) \\&=\frac{1}{2} \left[ \left (3x_1-\cos(x_2x_3)-\frac{3}{2} \right)^2 + \left(4x_1^2-625x_2^2+2x_2-1 \right)^2 +\right.\\
&{}\qquad\left. \left(\exp(-x_1x_2) + 20x_3 + \frac{10\pi-3}{3} \right)^2 \right],\end{align}

which we will attempt to minimize. As an initial guess, let us use

\mathbf{x}^{(0)}= \mathbf{0} = \begin{bmatrix}
 0 \\
 0 \\
 0 \\ \end{bmatrix}.
     

We know that

\mathbf{x}^{(1)}=\mathbf{0}-\eta_0 \nabla f(\mathbf{0}) = \mathbf{0}-\eta_0 J_G(\mathbf{0})^\top G(\mathbf{0}),

where the J_G is given by

J_G(\mathbf{x}) = \begin{bmatrix}
 3 & \sin(x_2x_3)x_3 & \sin(x_2x_3)x_2   \\
 8x_1 & -1250x_2+2 & 0 \\
 -x_2\exp{(-x_1x_2)} & -x_1\exp(-x_1x_2) & 20\\
     
\end{bmatrix}.

We calculate:

J_G(\mathbf{0}) = \begin{bmatrix}
 3 & 0 & 0\\
 0 & 2 & 0\\
 0 & 0 & 20
     
\end{bmatrix}, \qquad G(\mathbf{0}) = \begin{bmatrix}
 -2.5\\
 -1\\
 10.472
     
\end{bmatrix}.

Thus

\mathbf{x}^{(1)}= \mathbf{0}-\eta_0 \begin{bmatrix}
 -7.5\\
 -2\\
 209.44
     
\end{bmatrix},

and

f(\mathbf{0}) = 0.5 \left( (-2.5)^2 + (-1)^2 + (10.472)^2 \right) = 58.456.

Now, a suitable \eta_0 must be found such that

f\left (\mathbf{x}^{(1)}\right ) \le f\left (\mathbf{x}^{(0)}\right ) = f(\mathbf{0}).

This can be done with any of a variety of algorithms. One might also simply guess \eta_0=0.001, which gives

\mathbf{x}^{(1)}=\begin{bmatrix}
  0.0075  \\
  0.002   \\
 -0.20944 \\
     
\end{bmatrix}.

Evaluating the objective function at this value, yields

f \left (\mathbf{x}^{(1)}\right ) = 0.5 \left ((-2.48)^2 + (-1.00)^2 + (6.28)^2 \right ) = 23.306.

The decrease from f(\mathbf{0})=58.456 to the next step's value of

f \left (\mathbf{x}^{(1)}\right ) =23.306

is a sizable decrease in the objective function. Further steps would reduce its value further until an approximate solution to the system was found.


Comments
Gradient descent works in spaces of any number of dimensions, even in infinite-dimensional ones. In the latter case, the search space is typically a , and one calculates the Fréchet derivative of the functional to be minimized to determine the descent direction.
(1982). 9780080230368, Pergamon Press.

That gradient descent works in any number of dimensions (finite number at least) can be seen as a consequence of the Cauchy-Schwarz inequality, i.e. the magnitude of the inner (dot) product of two vectors of any dimension is maximized when they are . In the case of gradient descent, that would be when the vector of independent variable adjustments is proportional to the gradient vector of partial derivatives.

The gradient descent can take many iterations to compute a local minimum with a required , if the in different directions is very different for the given function. For such functions, , 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 (, Polyak, and Frank-Wolfe) and heavy-ball parameters (exponential moving averages and positive-negative momentum). The main examples of such optimizers are Adam, DiffGrad, Yogi, AdaBelief, etc.

Methods based on Newton's method and inversion of the using conjugate gradient techniques can be better alternatives.

(1992). 9780521431088, Cambridge University Press. .
(2025). 9783658114558, Springer Vieweg.
Generally, such methods converge in fewer iterations, but the cost of each iteration is higher. An example is the 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 algorithm, to find the "best" value of \eta. For extremely large problems, where the computer-memory issues dominate, a limited-memory method such as L-BFGS should be used instead of BFGS or the steepest descent.

While it is sometimes possible to substitute gradient descent for a local search algorithm, gradient descent is not in the same family: although it is an for local optimization, it relies on an rather than an explicit exploration of a .

Gradient descent can be viewed as applying Euler's method for solving ordinary differential equations x'(t)=-\nabla f(x(t)) to a . In turn, this equation may be derived as an optimal controller for the control system x'(t) = u(t) with u(t) given in feedback form u(t) = -\nabla f(x(t)).


Modifications
Gradient descent can converge to a local minimum and slow down in a neighborhood of a . Even for unconstrained quadratic minimization, gradient descent develops a zig-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
has proposed
(2025). 9781402075537, Springer.
a simple modification that enables faster convergence for convex problems and has been since further generalized. For unconstrained smooth problems, the method is called the fast gradient method (FGM) or the accelerated gradient method (AGM). Specifically, if the differentiable function f is convex and \nabla f is Lipschitz, and it is not assumed that f is strongly convex, then the error in the objective value generated at each step k by the gradient descent method will be bounded by \mathcal{O}\left({k^{-1}}\right). Using the Nesterov acceleration technique, the error decreases at \mathcal{O}\left({k^{-2}}\right). It is known that the rate \mathcal{O}\left({k^{-2}}\right) for the decrease of the is optimal for first-order optimization methods. Nevertheless, there is the opportunity to improve the algorithm by reducing the constant factor. The optimized gradient method (OGM) reduces that constant by a factor of two and is an optimal first-order method for large-scale problems.

For constrained or non-smooth problems, Nesterov's FGM is called the fast proximal gradient method (FPGM), an acceleration of the proximal gradient method.


Momentum or heavy ball method
Trying to break the zig-zag pattern of gradient descent, the momentum or heavy ball method uses a momentum term in analogy to a heavy ball sliding on the surface of values of the function being minimized, or to mass movement in Newtonian dynamics through a medium in a conservative force field. Gradient descent with momentum remembers the solution update at each iteration, and determines the next update as a linear combination of the gradient and the previous update. For unconstrained quadratic minimization, a theoretical convergence rate bound of the heavy ball method is asymptotically the same as that for the optimal conjugate gradient method.

This technique is used in stochastic gradient descent and as an extension to the algorithms used to train artificial neural networks. Part of a lecture series for the online course Neural Networks for Machine Learning . In the direction of updating, stochastic gradient descent adds a stochastic property. The weights can be used to calculate the derivatives.


Extensions
Gradient descent can be extended to handle constraints by including a 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 for monotone inclusions (which includes convex programming and variational inequalities).
(2025). 9781441995681, Springer.

Gradient descent is a special case of using the squared Euclidean distance as the given Bregman divergence.


Theoretical properties
The properties of gradient descent depend on the properties of the objective function and the variant of gradient descent used (for example, if a step is used). The assumptions made affect the convergence rate, and other properties, that can be proven for gradient descent. For example, if the objective is assumed to be strongly convex and lipschitz smooth, then gradient descent converges linearly with a fixed step size. Looser assumptions lead to either weaker convergence guarantees or require a more sophisticated step size selection.


See also


Further reading


External links

Page 1 of 1
1
Page 1 of 1
1

Account

Social:
Pages:  ..   .. 
Items:  .. 

Navigation

General: Atom Feed Atom Feed  .. 
Help:  ..   .. 
Category:  ..   .. 
Media:  ..   .. 
Posts:  ..   ..   .. 

Statistics

Page:  .. 
Summary:  .. 
1 Tags
10/10 Page Rank
5 Page Refs
4s Time