Gradient descent.

Gradient descent finds the best line by starting somewhere and taking small steps downhill on the error. The data are twelve students’ study hours and exam scores. Every point on the error map is one possible line.

From Chapter 3: Gradient Descent and Chapter 18: Optimizers, which explain these figures step by step.

Figure

Gradient descent, seen two ways

1, 481.5, 532, 503, 603.5, 574, 665, 685.5, 756, 717, 828, 839, 91
5.31, 67lowest
  • Current line / position
  • Best line
  • Equal error
Step
0
Slope w
0.00
Bias b
50.0
Error
466.8
0.030
Each step looks at

Before the first step you can drag the orange dot on the map to start somewhere else.

Left: the line moving through the data. Right: the same run as a path on the map of the error. Each step can use all twelve students, or only a few, to estimate the downhill direction. Try it: run it with all 12, then with 4, then with 1. Compare how straight the path is, and where it ends up.
Figure

Three learning rates

η = 0.005η = 0.08
  • Your learning rate
  • Small (0.005)
  • Well chosen (0.08)
Your η
0.050
Error after 40 steps
6.2
Verdict
Reaches the bottom
Breaks above
0.164
0.050
Each curve shows the error after every step, starting from the same flat line. Try it: slide the learning rate slowly upward from 0.005. Find roughly where the run is fastest, then keep going until it breaks.
Figure

Four ways down the same valley

0, 0lowest-9, 3-9, 3-9, 3-9, 3
  • Plain SGD (rate 0.1)
  • Momentum (rate 0.1, momentum 0.9)
  • RMSProp (rate 0.3)
  • Adam (rate 0.5)
Plain SGD
height 13.050
Momentum
height 13.050
RMSProp
height 13.050
Adam
height 13.050
Step 0 of 100
Four optimizers start from the same point in a long, narrow valley, where plain gradient descent has to use a small, cautious learning rate. Try it: press Race and watch the order in which they arrive. Reset and use Step to follow the first ten moves one at a time.

Learn the ideas behind it

More playgrounds

Search

    The Book of Machine Learning
    Search
    Reading settings
    Text size
    Colours

    Saved in this browser only.

    Keyboard shortcuts
    /
    Search the book
    ← →
    Previous and next chapter
    g
    Glossary
    c
    Table of contents
    e
    Jump to the exercises
    t
    Reading settings
    ?
    Show this list
    Esc
    Close a window or pop-in