ArticleslgStudy

mathematics

Gradient descent

Gradient descent is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Gradient descent rather than just read about it. In short: Gradient descent is a method for unconstrained mathematical optimization. It is a first-order iterative algorithm for minimizing a differentiable multivariate function.

Gradient descent — main illustration
Gradient descent — illustration

Key takeaways

  • Gradient descent belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Gradient descent to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Gradient descent from memory before moving on to harder problems.

Reference excerpt

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

The idea is to take repeated steps in the opposite direction of the gradient (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. Gradient descent should not be confused with local search algorithms, although both are iterative methods for optimization. Gradient descent is particularly useful in machine learning and artificial intelligence for minimizing the cost or loss function. Gradient descent is generally attributed to Augustin-Louis Cauchy, who first suggested it in 1847. Jacques Hadamard independently proposed a similar method in 1907. Its convergence properties for non-linear optimization problems were first studied by Haskell Curry 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(𝐱) is defined and differentiable in a neighborhood of a point 𝐚, then f(𝐱) decreases fastest if one goes from 𝐚 in the direction of the negative gradient of f at 𝐚,i.e.,−∇f(𝐚). It follows that, if

𝐚n+1=𝐚n−η∇f(𝐚n) for a small enough step size or learning rate η∈ℝ+, then f(𝐚𝐧)≥f(𝐚𝐧+𝟏). In other words, the term η∇f(𝐚) is subtracted from 𝐚 because we want to move against the gradient, toward the local minimum. With this observation in mind, one starts with a guess 𝐱0 for a local minimum of f, and considers the sequence 𝐱0,𝐱1,𝐱2,… such that

𝐱n+1=𝐱n−ηn∇f(𝐱n), n≥0. We have a monotonic sequence

f(𝐱0)≥f(𝐱1)≥f(𝐱2)≥⋯, so the sequence (𝐱n) converges to the desired local minimum. Note that the value of the step size η 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 convex and ∇f Lipschitz) and particular choices of η. Those include the sequence ηn=|(𝐱n−𝐱n−1)⊤[∇f(𝐱n)−∇f(𝐱n−1)]|‖∇f(𝐱n)−∇f(𝐱n−1)‖2 as in the Barzilai-Borwein method, or a sequence ηn satisfying the Wolfe conditions (which can be found by using line search). When the function f is convex, 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 contour lines, 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 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 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 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 people happen to have at that 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 want 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 as not to go off track. In this analogy, the people 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 slope of the function at that point. The instrument used to measure steepness is differentiation. The direction they choose to travel in aligns with the gradient 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 η that is too small would slow convergence, and a η too large would lead to overshoot and divergence, finding a good setting of η 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 𝐩n and step size ηn and consider the more general update:

𝐚n+1=𝐚n−ηn𝐩n. Finding good settings of 𝐩n and ηn requires some thought. First of all, we would like the update direction to point downhill. Mathematically, letting θn denote the angle between −∇f(𝐚𝐧) and 𝐩n, this requires that cos⁡θ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:

… excerpt ends here. Continue reading the full article.

Illustrations

Gradient descent: Illustration of gradient descent on a series of level sets
Illustration of gradient descent on a series of level sets
Gradient descent: Negative gradient in direction of steepest descent.
Negative gradient in direction of steepest descent.
Gradient descent: Fog in the mountains
Fog in the mountains
Gradient descent: The steepest descent algorithm applied to the Wiener filter[12]
The steepest descent algorithm applied to the Wiener filter[12]
Gradient descent: Convergence path of steepest descent method for A = [[2, 2], [2, 3]]
Convergence path of steepest descent method for A = [[2, 2], [2, 3]]

Worked examples

Example 1 — a first encounter with Gradient descent

Start with the simplest possible case. Write down what Gradient descent claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Gradient descent before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Gradient descent ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Gradient descent

In research
Gradient descent appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Gradient descent in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Gradient descent is common in secondary-school and first-year university syllabi. It links to neighbouring topics First order methods, Gradient methods, Mathematical optimization, so understanding it makes those chapters shorter.
In everyday life
Look for Gradient descent outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Gradient descent” →

How to study Gradient descent in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Gradient descent means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Gradient descent out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Gradient descent in simple terms?

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

Why does Gradient descent matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Gradient descent?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Gradient descent.

Tags

  • First order methods
  • Gradient methods
  • Mathematical optimization
  • Optimization algorithms and methods

Keep exploring