Log inStart free
LESSON 2.26 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Gradient descent

Watch two weights walk down a loss surface, one gradient step at a time.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 2.26 · DESCENT BAYL(0.02, 1.2) = 15.4 · MEAN LOSS OF 8 EXAMPLES
01
Stage 1 of 6 · The objective
An objective function scores the weights with one number. Here L is the mean loss of 8 examples: 15.4 at the start.
Explain it simply

The ochre dot is the start: two weights, w₁ and w₂. The loss L gives them one score, here 15.4. It has two parts, and most of it, 14.4, comes from w₂. Training means finding the weights with the lowest L.

The plane of the two weights w₁ and w₂, with the start (0.02, 1.2). Its loss L is 15.4: the floor part 1 plus the wall part 14.4.

weights w₁, w₂, their steps and the learning rate ηloss L and its gradient ∇Lsaddle point and minimacontour lines of L
the weights w = (w₁, w₂)loss L per step (log scale)the two parts of L−3−2−10123−101w₁w₂start (0.02, 1.2)10⁴110⁻⁴10⁻⁸050100step tLfloor part (w₁² − 4)²/161wall part 10·w₂²14.4L = 1 + 14.4 = 15.4the weights w = (w₁, w₂)loss L per step (log scale)the two parts of L−3−2−10123−101w₁w₂start (0.02, 1.2)10⁴110⁻⁴10⁻⁸050100step tLfloor part (w₁² − 4)²/161wall part 10·w₂²14.4L = 1 + 14.4 = 15.4
Toy: the 2.C2 surface · 2 weights · L = the mean loss of 8 examples · full-batch steps
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
L(w)=(w12−4)216+10 w22\sy{L}{grad}{L}(w) = \frac{(\sy{w1}{param}{w_1}^2 - 4)^2}{16} + 10\,\sy{w2}{param}{w_2}^2
L(0.02, 1.2)=(0.022−4)216+10⋅1.22=1+14.4=15.4L(0.02,\ 1.2) = \tfrac{(0.02^2 - 4)^2}{16} + 10\cdot 1.2^2 = 1 + 14.4 = 15.4

The loss adds a floor part from w₁ and a wall part from w₂.

Common mix-ups

MYTHA bigger learning rate always reaches the bottom faster.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01If η goes from 0.08 to 0.11, is L lower or higher after 20 steps?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.