Neuron 101

Math foundations / Partial derivatives and the gradient

Türkçe

Plate9

Unit 1 · Topic 9 of 11

Partial derivatives and the gradient

Medium, 8 min, 7 steps

w₁w₂
Keyboard: left and right arrows change the step, space plays and pauses.

Step 1 of 7 Map

A map of the loss surface

A loss that depends on two weights: f(w₁, w₂) = w₁² / 4 + w₂². Seen from above, the contour lines are nested ellipses and the darkest region is the bottom.

Open in Colab
  1. def f(w1, w2):
  2. return w1 ** 2 / 4 + w2 ** 2
  3. w1, w2 = 3.0, 1.5
  4. g1 = w1 / 2
  5. g2 = 2 * w2
  6. lr = 0.3
  7. w1, w2 = w1 - lr * g1, w2 - lr * g2
  8. print(g1, g2, f(w1, w2))
w1
3
w2
1.50
f
4.50
g1
1.50
g2
3