Neuron 101

Learning from examples / Gradient descent

Türkçe

Plate27

Unit 3 · Topic 6 of 11

Gradient descent

Medium, 8 min, 11 steps

lowest lossloss, step by step
Keyboard: left and right arrows change the step, space plays and pauses.

Step 1 of 11 Start

The ball starts somewhere random

The weight starts at w = −1 and the loss there is 16.50. The goal is to reach the bottom of the valley, where the loss is lowest.

Open in Colab
  1. def kayip(w):
  2. return (w - 3) ** 2 + 0.5
  3. def egim(w):
  4. return 2 * (w - 3)
  5. w = -1.0
  6. lr = 0.2
  7. for adim in range(8):
  8. grad = egim(w)
  9. w = w - lr * grad
  10. print(adim + 1, w, kayip(w))
adim
0
w
−1
lr
0.20
grad
−8
kayip
16.50