Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Let us recall the (unconstrained) optimization problem at hand

minimize⁡f0(x)subject to⁡x∈Rn\begin{array}{ll} \minimize &\quad f_0(x)\\ \st & \quad x \in \mathbb{R}^n \end{array}

The gradient descent method attempts at solving (1) using the following algorihtm.

Under suitable assumptions about the objective f0f_0, and proper choice of the stepsize αk\alpha_k at each iteration, one can show that the sequence of iterates produced by gradient descent converges to a stationary point of the cost function. We’ll cover in more detail in Chapter 5.

Step-size selection strategies

Choosing an appropriate step-size is crucial for the efficiency and convergence of gradient descent. The step-size determines how far each iteration moves towards a (local) minimum, and poor choices can lead to slow progress or even divergence.

Constant step-size

This first choice is also the simplest (and still used in many situations).

Intuitively, the stepsize α\alpha should be chosen as a compromise between the rate of convergence and convergence guarantees. Indeed if α\alpha is “too small” then convergence of the algorithm will be very slow; on the contrary if α\alpha is chosen “too large”, then there exist a risk of divergence of the algorithm.

This strategy guarantees the best decrease of the objective for the current descent direction ∇f0(x(k))\nabla f_0(x^{(k)}). However, a major drawback is that calculating the optimal step size can be as difficult as the original problem and/or very computationally expensive.

Example 1 (adapted from Boyd & Vandenberghe (2004, §9.3.2))

Consider the optimization problem

minimize⁡f0(x):=12xTQxsubject to⁡x∈R2 with Q=[100η],η>0\begin{array}{ll} \minimize &\quad f_0(x):= \frac{1}{2} x^T Qx\\ \st & \quad x \in \mathbb{R}^2 \end{array} \quad \text{ with } Q = \begin{bmatrix} 1 & 0 \\ 0 & \eta \end{bmatrix}, \eta > 0
  1. Calculate ∇f0(x)\nabla f_0(x)

  2. Give the explicit expression for x(k+1)x^{(k+1)} in terms of x(k)x^{(k)}

  3. Give the expression for x(1)x^{(1)} in terms of α0\alpha_0 for x(0)=[η,1]⊤x^{(0)} = [\eta, 1]^\top

  4. Find the optimal step size for this iteration

  5. Show that the iterations with optimal step size take the form:

    x1(k)=η(η−1η+1)kx2(k)=(−η−1η+1)kx_1^{(k)} = \eta \left(\frac{\eta - 1}{\eta + 1}\right)^k \quad x_2^{(k)} = \left(-\frac{\eta - 1}{\eta + 1}\right)^k

This last strategy searches a step size αk\alpha_k that sufficiently decreases the objective f0f_0 at each iteration, i.e., such that f0(x(k+1))−f0(x(k))≤ck<0f_0(x^{(k+1)}) - f_0(x^{(k)}) \leq c_k < 0 where ckc_k is some (negative) constant. Backtracking is the most commonly used approach in practice, for which many ``recipes’’ for the choice of ckc_k exist.

In this course, we will focus on a standard condition known as Armijo’s condition (also simply referred to as backtracking linesearch condition). In the case of gradient descent, this condition requires that the stepsize αk\alpha_k sufficiently decreases the cost function f0f_0 such that

f0(x(k+1))≤f0(x(k))−sαk∥∇f0(x(k))∥22f_0(x^{(k+1)}) \leq f_0(x^{(k)}) - s \alpha_k \Vert \nabla f_0 (x^{(k)})\Vert_2^2

where s∈(0,0.5)s \in (0, 0.5) is a parameter of the method.

Illustration The following code snippets show how backtracking iteratively “test” step sizes until the sufficient decrease condition is satisfied.

Source
<Figure size 1400x1000 with 4 Axes>

In a nutshell:

Comparison of step-size strategies

To compare the effect of the proposed step-size selection strategies, let us consider the following example, adapted from Boyd & Vandenberghe (2004).

minimize⁡f0(x):=ex1+3x2−0.1+ex1−3x2−0.1+e−x1−0.1subject to⁡x∈R2\begin{array}{ll} \minimize &\quad f_0(x):=e^{x_1+3x_2 - 0.1} + e^{x_1 -3x_2 - 0.1} + e^{-x_1 - 0.1}\\ \st & \quad x \in \mathbb{R}^2 \end{array}

Let us plot the objective.

<Figure size 800x600 with 2 Axes>

We will now compare the three step-sizes: fixed, optimal, and with backtracking. For simplicity, we only implemented a fixed number of iterations; recall that in practice you need a good stopping criterion!

In addition, we will a backtracking strategy in which the value of α\alpha is not reset to α0\alpha_0 at each iteration; this is used in some context to save some computation time. You can see the effect by uncommenting this line in the code.

Source
backtracking kicks in at iter 2: current alpha = 0.18000000000000002
backtracking kicks in at iter 3: current alpha = 0.16200000000000003
backtracking kicks in at iter 3: current alpha = 0.14580000000000004
backtracking kicks in at iter 13: current alpha = 0.13122000000000003
<Figure size 800x600 with 2 Axes>
<Figure size 800x600 with 1 Axes>

This experiment shows that among the three methods, the simpler (fixed-step size) is also the slowest. Both backtracking and optimal step size converge faster, with an advantage to the optimal step-size strategy for this configuration. However, this is not always the case: there are situations in which backtracking can outperform (sometimes in a striking way) the optimal step-size strategy.

Here is an example, starting from a different point and with updated parameters. (note we reset α=α0\alpha = \alpha_0 in each iteration).

Source
backtracking kicks in at iter 0: current alpha = 0.3
backtracking kicks in at iter 0: current alpha = 0.09
backtracking kicks in at iter 0: current alpha = 0.027
backtracking kicks in at iter 1: current alpha = 0.3
backtracking kicks in at iter 2: current alpha = 0.3
backtracking kicks in at iter 2: current alpha = 0.09
backtracking kicks in at iter 3: current alpha = 0.3
backtracking kicks in at iter 3: current alpha = 0.09
backtracking kicks in at iter 4: current alpha = 0.3
backtracking kicks in at iter 5: current alpha = 0.3
backtracking kicks in at iter 5: current alpha = 0.09
backtracking kicks in at iter 6: current alpha = 0.3
backtracking kicks in at iter 7: current alpha = 0.3
backtracking kicks in at iter 7: current alpha = 0.09
backtracking kicks in at iter 8: current alpha = 0.3
backtracking kicks in at iter 9: current alpha = 0.3
backtracking kicks in at iter 10: current alpha = 0.3
backtracking kicks in at iter 10: current alpha = 0.09
backtracking kicks in at iter 11: current alpha = 0.3
backtracking kicks in at iter 12: current alpha = 0.3
backtracking kicks in at iter 12: current alpha = 0.09
backtracking kicks in at iter 13: current alpha = 0.3
backtracking kicks in at iter 14: current alpha = 0.3
backtracking kicks in at iter 14: current alpha = 0.09
backtracking kicks in at iter 15: current alpha = 0.3
backtracking kicks in at iter 16: current alpha = 0.3
backtracking kicks in at iter 16: current alpha = 0.09
backtracking kicks in at iter 17: current alpha = 0.3
backtracking kicks in at iter 18: current alpha = 0.3
backtracking kicks in at iter 19: current alpha = 0.3
backtracking kicks in at iter 19: current alpha = 0.09
backtracking kicks in at iter 20: current alpha = 0.3
backtracking kicks in at iter 21: current alpha = 0.3
backtracking kicks in at iter 22: current alpha = 0.3
backtracking kicks in at iter 22: current alpha = 0.09
backtracking kicks in at iter 24: current alpha = 0.3
<Figure size 800x600 with 2 Axes>
<Figure size 800x600 with 1 Axes>

In this example backtracking outperforms the optimal step-size strategy; it is less prone to zig-zags, and thus converges faster. Both methods converge faster than the fixed step-size strategy.

Takeaway: step-size selection strategies

References
  1. Boyd, S. P., & Vandenberghe, L. (2004). Convex optimization. Cambridge University Press.