Neuron 101

A neural network from scratch / The limit of a single line

Türkçe

Plate46

Unit 5 · Topic 4 of 12

The limit of a single line

Medium, 7 min, 11 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 11 Gate

Exclusive or

Exclusive or, XOR: the output is 1 when only one of the two inputs is 1. Red circles are dots with output 1, blue squares those with 0. Tap a dot to change its expected output.

Open in Colab
  1. X = [(0, 0), (0, 1), (1, 0), (1, 1)]
  2. Y = [0, 1, 1, 0]
  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
  16. print(hata)
w1
0.50
w2
−0.40
b
0.10
epok
0
guncelleme
0