Neuron 101

A neural network from scratch / Perceptron learning rule

Türkçe

Plate45

Unit 5 · Topic 3 of 12

Perceptron learning rule

Medium, 8 min, 9 steps

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

Step 1 of 9 Gate

A logic gate

The four dots are every state of two inputs: (0, 0), (0, 1), (1, 0), (1, 1). Red circles have output 1, blue squares 0. Tap a dot to change its expected output; you can build any gate you like.

Open in Colab
  1. X = [(0, 0), (0, 1), (1, 0), (1, 1)]
  2. Y = [0, 0, 0, 1]
  3. w1, w2, b, lr = 0.5, -0.4, 0.1, 0.2
  4. for epok in range(10):
  5. hata = 0
  6. for (a, c), y in zip(X, Y):
  7. z = w1 * a + w2 * c + b
  8. fark = y - (z >= 0)
  9. if fark:
  10. hata += 1
  11. w1 += lr * fark * a
  12. w2 += lr * fark * c
  13. b += lr * fark
  14. if hata == 0:
  15. break
w1
0.50
w2
−0.40
b
0.10
epok
0
guncelleme
0