Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 8

Learning Rate's Impact on Gradient Descent Convergence

Recommended resources

Welcome to our next lesson. In our previous session, we implemented vanilla gradient descent from scratch, establishing how to iteratively update model parameters to minimize a loss function. We concluded with a visual intuition of how the learning rate, , is a critical parameter: too small, and convergence is slow; too large, and the algorithm can overshoot the minimum and diverge.

Today, we will build directly on that foundation to achieve this lesson's learning outcome: to analyse the effect of the learning rate on gradient descent convergence. We will move beyond visual intuition to a more rigorous, mathematical understanding of this process. You'll learn how properties of the loss function, specifically its curvature, determine the optimal learning rate and dictate the convergence behaviour of the algorithm. This analysis is fundamental for training machine learning models effectively and is a key topic for your exam preparation.

1. The Learning Rate: A Visual Recap

Let's begin by revisiting the core idea with a more detailed visual. In the last lesson, we saw that the gradient descent update rule is:

The learning rate scales the gradient vector to determine the step size. The choice of has a dramatic impact on the optimization process.

This figure illustrates how the learning rate affects gradient descent. The top row shows the steps taken on a 1D loss function \(L(w)\). The bottom row shows the corresponding loss value over training epochs for different learning rates.

Let's break down what this image shows:

  • Learning rate too low (blue): The algorithm takes very small, cautious steps. As the bottom plot shows, the loss decreases reliably but very slowly. This can be computationally expensive.
  • Good learning rate (green): The steps are large enough to make rapid progress but small enough not to overshoot the minimum. The loss decreases quickly and smoothly, leading to efficient convergence.
  • High learning rate (red): The steps are too large. The algorithm overshoots the minimum, bouncing from one side of the valley to the other. While it might eventually converge, the path is inefficient, and the loss oscillates as seen in the bottom plot.
  • Learning rate much too high (top right): The steps are so large that each update sends the parameter further away from the minimum. The loss function diverges, rapidly increasing instead of decreasing.

The following video provides a concise recap of these scenarios.

Stanford CS229: Machine Learning - Linear Regression and Gradient Descent | Lecture 2 (Autumn 2018)

This segment from Andrew Ng's Stanford lecture clearly explains the practical consequences of setting the learning rate too high or too low.

Please watch the section from 00:36:03 to 00:37:11, where he discusses the effects of choosing \alpha (his notation for the learning rate) and how to diagnose a poor choice by plotting the cost function.


2. Towards a Formal Analysis: The Role of Curvature

The visual intuition is clear, but to analyse convergence properly, we need to answer why a certain learning rate is good or bad. The answer lies in the curvature of the loss function.

Think of the loss landscape. If you are in a very steep, narrow valley (high curvature), you need to take small, careful steps. If you're on a wide, gentle plain (low curvature), you can afford to take much larger steps.

In a one-dimensional problem, the curvature is simply the second derivative, . In multiple dimensions, this is captured by the Hessian matrix, , which we studied in a previous lesson. The eigenvalues of the Hessian tell us about the curvature along different directions.

For a simple quadratic loss function, we can use this information to derive the optimal learning rate.

Learning Rates and the Convergence of Gradient Descent

This article provides an excellent mathematical derivation of the optimal learning rate for a 1D quadratic error function, which is a good approximation for many loss functions near their minimum.

Please read the first two main sections of the article. Begin with the introduction, which recaps the different cases we've just discussed. Note the relationship it draws between the learning rate \eta and the optimal learning rate \eta_{opt}. Next, work through the section "Deriving the optimal learning rate in one dimensional space". You can focus on one of the two methods (Taylor Series or Graphical); both lead to the same result. The key outcome is the formula for \eta_{opt}. Pay close attention to the NOTE at the end of this section, which states that divergence occurs when \eta > 2 \eta_{opt}. This is a precise, analytical explanation for the diverging behaviour we saw visually.

From the article, for a quadratic error function , the optimal learning rate that reaches the minimum in a single step is:

This elegant result formally connects the best step size to the function's curvature. The condition for convergence is . This gives us a hard mathematical boundary for the learning rate.


3. Convergence Analysis in Multiple Dimensions

Most machine learning problems involve thousands or millions of parameters, so we need to extend this analysis to higher dimensions. As mentioned, the Hessian matrix and its eigenvalues replace the simple second derivative.

To provide guarantees about convergence, we often rely on certain assumptions about the loss function . Two of the most important are L-smoothness and m-strong convexity.

  • L-smoothness means the function's curvature is bounded from above. Intuitively, the function can't curve "too sharply". Formally, a function is -smooth if the largest eigenvalue of its Hessian is at most . This property is what prevents gradient descent from wildly overshooting if the learning rate is chosen correctly.

  • m-strong convexity means the function's curvature is bounded from below. Intuitively, the function is "at least as curved as a quadratic". Formally, a function is -strongly convex if the smallest eigenvalue of its Hessian is at least . This property ensures there is a unique global minimum and prevents the landscape from becoming too flat, which would slow down convergence.

The following text provides the formal theorems for convergence under these assumptions.

3.5. Gradient descent and its convergence analysis

This textbook section offers a rigorous analysis of gradient descent convergence, which is exactly what you need for a deep understanding and for your exams.

Please read the following parts of section 3.5.2, "Convergence analysis": Start by reading the definition of an L-smooth function. This formalizes the idea of bounded curvature. Carefully study the Theorem (Convergence of Gradient Descent in the Smooth Case) and its proof. The key result here is that for an L-smooth function, setting the learning rate \alpha = 1/L guarantees that the gradient norm will converge to zero. Next, read about the Smooth and strongly convex case. Study the Theorem (Convergence of Gradient Descent in the Strongly Convex Case). Notice that with this stronger assumption, we get a much faster exponential convergence rate for the function value itself, not just the gradient. The rate depends on the ratio m/L.

Let's summarise the crucial takeaways from this rigorous analysis:

  1. For an -smooth function, if we set the learning rate , gradient descent is guaranteed to converge (specifically, the gradient norm will go to zero). The convergence rate is of the order , where is the number of steps.
  2. For a function that is both -smooth and -strongly convex, setting gives a much faster exponential convergence rate. The error decreases by a factor of at each step.
  3. The ratio is called the condition number of the function. If is large (meaning the function is very steep in some directions but very flat in others), convergence will be slow. This explains why scaling your input features is so important—it often improves the condition number of the loss function.

4. Practical Strategies for Setting the Learning Rate

The theoretical results are powerful, but computing the Hessian and its eigenvalues (, ) is computationally infeasible for large models. So, how do we set the learning rate in practice?

A. Manual Tuning

The most common method is simply to try several values and see what works. As Andrew Ng mentioned in the video, you can try values on a logarithmic scale (e.g., 0.1, 0.01, 0.001, ...) and plot the training loss for each. You then pick the one that gives the fastest, most stable convergence.

B. Learning Rate Schedules

Instead of a fixed , it's often beneficial to decrease it during training. You can start with a relatively high learning rate for fast initial progress and then reduce it to take smaller, more refined steps as you approach the minimum. This is known as a learning rate schedule or learning rate decay.

Stanford CS229: Machine Learning - Linear Regression and Gradient Descent | Lecture 2 (Autumn 2018)

This short clip discusses a common reason for using learning rate decay in the context of Stochastic Gradient Descent (SGD), but the principle applies more broadly.

Watch from 00:50:03 to 00:50:28. The key idea is that reducing the learning rate over time helps the algorithm settle closer to the minimum by reducing the size of the update steps.

C. Adaptive Methods: Line Search

A more sophisticated approach is to find the optimal step size at each iteration. Instead of fixing , we can treat it as a variable to be optimized at each step . This is called a line search. The process is:

  1. At point , compute the descent direction .
  2. Define a 1D function of the step size : .
  3. Find the value of that minimizes this 1D function, .
  4. Update the parameters: .

This turns the difficult high-dimensional optimization of into a sequence of simpler 1D optimizations for .

Intro to Gradient Descent || Optimizing High-Dimensional Equations

This video by Dr. Trefor Bazett provides an excellent visual and conceptual explanation of the line search method.

Watch these two segments: First, watch from 00:04:11 to 00:05:21 for a recap of the problems with a fixed step size. Then, watch from 00:05:21 to 00:08:39 to understand how line search works by turning the problem into a series of 1D optimizations, leading to much faster convergence.

While powerful, line search adds computational overhead at each step. In modern deep learning, more popular adaptive methods like Adam and RMSprop implicitly adjust the learning rate for each parameter, but they are built on the same foundational ideas we've covered today.


Conclusion

In this lesson, we deepened your understanding of gradient descent by moving from a purely visual feel for the learning rate to a rigorous analysis of its effect on convergence.

Here are the main takeaways:

  • The choice of learning rate is critical: it can lead to slow convergence, efficient convergence, oscillation, or divergence.
  • The ideal learning rate is related to the curvature of the loss function, which is measured by the second derivative (in 1D) or the eigenvalues of the Hessian matrix (in N-D).
  • For functions that are L-smooth, a learning rate guarantees convergence.
  • If a function is also m-strongly convex, convergence is exponentially fast, at a rate determined by the condition number .
  • In practice, since computing and is often infeasible, we rely on strategies like manual tuning, learning rate schedules, and adaptive methods like line search.

You are now equipped not only to implement gradient descent but also to analyze and troubleshoot its convergence, a crucial skill for any machine learning practitioner.

Having established the core optimization machinery, we are ready to take a step back. In the next lesson, we will begin our second module, "Principles of Statistical Learning," by formally defining the components of a supervised learning problem: the hypothesis class, loss function, and risk. This will provide the general framework into which specific models and algorithms, like the ones we'll train with gradient descent, will fit.