본문으로 건너뛰기
L1.6

Gradient Descent and Learning Rate

About 24 min

Goal

By the end of this lesson, you can trace gradient-descent updates, explain what the learning rate controls, and diagnose slow, stable, or unstable optimization from a short loss history.

Direction and step size solve different parts of the problem​

Suppose a model has one adjustable value, w, and the loss is smallest at w = 3.

If w starts below 3, we want it to move upward. If it starts above 3, we want it to move downward. A real model has many adjustable values, so we need a repeatable rule instead of trying every possible setting.

The gradient tells us the local uphill direction of the loss. Gradient descent moves in the opposite direction:

parameter = parameter - learning_rate × gradient

Two ideas are packed into that line:

  • the gradient supplies a local direction;
  • the learning rate controls how far the update moves.

Keeping those roles separate makes optimization easier to reason about.

Trace one update​

For the toy loss (w - 3)², the gradient is 2(w - 3). You do not need to derive that formula yet.

At w = 0, the gradient is -6. With learning rate 0.1:

new w = 0 - 0.1 × (-6) = 0.6

Subtracting a negative value moves w upward, toward the low-loss point. At w = 5, the gradient is positive, so subtracting it moves w downward.

Direction and step size

The target is w = 3. Change the learning rate and step through the path to see how the same local direction can produce slow, useful, or unstable movement.

Step 0 · w = 0.00 · loss = 9.000
0parameter wloss

Why learning rate matters​

Imagine walking downhill in fog. Tiny steps can be safe but slow. Medium steps can make steady progress. Giant jumps can cross the valley and bounce from side to side.

The same pattern appears in optimization:

  • a too-small learning rate often decreases loss slowly;
  • a useful rate makes clear, stable progress;
  • a too-large rate can oscillate or make loss grow.

There is no single learning rate that works for every problem. Feature scale, model shape, optimizer, and loss geometry all affect useful step sizes.

Compare paths in the Lab​

The Lab runs the same one-parameter problem with several learning rates.

  1. Click Run with learning_rates = [0.02, 0.2, 1.1].
  2. Read first gradients:. All three runs begin at the same w = 0.0, so they should start with the same gradient.
  3. Read loss paths:. The 0.02 path should shrink slowly, the 0.2 path should shrink quickly, and the 1.1 path should grow as it overshoots farther on each step.
  4. Find learning_rates = [0.02, 0.2, 1.1]. Change only 1.1 to 0.9.
  5. Before running, predict that the new 0.9 path will still bounce across the target but that the loss will shrink instead of grow.
  6. Click Run and compare the 0.9 loss path with the original 1.1 path.
  7. For one boundary-case experiment, change only 0.9 to 1.0. Run again, read w paths:, and observe that the loss stays constant while w jumps back and forth across the target.
  8. Press Reset afterward.

Python used here: reading for/range loops and dictionary comprehensions (P1 — comprehensions).

Loading lab…

A fair learning-rate experiment keeps the starting point, number of steps, loss, and data fixed. Otherwise a changed result may have more than one explanation.

Optimization evidence is not generalization evidence​

A decreasing training loss means the optimizer is improving the chosen training objective. It does not prove that the model will work well on held-out data.

Later lessons will keep these questions separate:

  • Did optimization fit the training objective?
  • Does the fitted model generalize to new examples?

Both matter.

Debug the path, not just the endpoint​

When optimization behaves strangely, inspect the sequence:

  • Is loss decreasing, flat, oscillating, or exploding?
  • Are updates moving in the expected direction?
  • Did only the learning rate change?
  • Are feature scales making one direction dominate?
  • Does a smaller step stabilize the run?

This turns “training failed” into a testable diagnosis.

Quick Check

1. What does the gradient contribute to a gradient-descent update?
2. What does the learning rate control?
3. Which comparison best isolates the effect of learning rate?

0 of 3 questions answered.

Key Takeaways

  • Gradient descent repeatedly moves parameters using local loss information.
  • The gradient supplies direction; the learning rate supplies step size.
  • Too-small rates can be slow, while too-large rates can overshoot or diverge.
  • Loss histories reveal optimization behavior better than one final number.
  • Better training loss is not automatically better held-out performance.

Next Lesson

Next, you will see why feature scale can change the geometry of optimization and how to fit scaling without leaking evaluation information.

References

Lesson actions

Completion is stored locally on this device.

View progress