Gradient Descent with Momentum
Lesson Introduction
Welcome back! Today, we'll explore Gradient Descent with Momentum. You've already familiarized yourself with basic gradient descent. However, sometimes gradient descent is slow and gets stuck, especially on bumpy paths to the minimum.
So, how do we speed it up? We use momentum. Imagine pushing a heavy shopping cart. Instead of stopping and starting, you build momentum. This helps you move faster. By the end of this lesson, you'll understand how gradient descent with momentum works, implement it in Python, and see how it improves optimization.
Introducing Momentum
Momentum in optimization is like a push in physical movement. It reduces oscillations (back-and-forth movements) as you head toward the minimum point. Essentially, it helps you move down faster and more steadily.
Let's look at the formulas for momentum:
Here's what these terms mean:
- : Velocity at time step . It shows speed and direction.
- : This is the common symbol for the parameters of the function we're optimizing, similar to variables like and in a function .
- : Momentum term, usually between 0 and 1. Higher values mean more momentum.
- : Learning rate, controlling step size.
- : Gradient of function at the current point.
- : Updated parameter at time step , bringing us closer to the minimum.
How Velocity Works in Gradient Descent with Momentum
In the basic gradient descent, the update to the parameters is directly proportional to the gradient of the function. However, this approach can be slow due to the oscillations around the minimum.
With momentum, the velocity term is introduced to accelerate gradient vectors in the right directions. Here's a detailed breakdown of how the velocity term works:
- Initial Update (at )
- Velocity starts at zero: .
- The first update is similar to basic gradient descent.
- Subsequent Updates (at )
- The velocity is updated with a fraction of the previous velocity, , scaled by , and the current gradient, scaled by .
- This means that the update direction is influenced not just by the current gradient but also by the past gradients, providing a smoothing effect.
- The point is updated using this velocity.
In essence, the velocity term accumulates the gradients of past steps to create a more stable and faster approach toward the minimum.

