Neuron 101

A neural network from scratch / Hidden layer

Türkçe

Plate47

Unit 5 · Topic 5 of 12

Hidden layer

Medium, 7 min, 7 steps

0a1b
Keyboard: left and right arrows change the step, space plays and pauses.

Step 1 of 7 Input

Two inputs

The inputs are a = 0, b = 1. Tap an input node to type 0 or 1; the network computes all four cases.

Open in Colab
  1. def adim(z):
  2. return 1 if z >= 0 else 0
  3. w11, w21, b1 = 1.0, 1.0, -0.5
  4. w12, w22, b2 = 1.0, 1.0, -1.5
  5. v1, v2, c = 1.0, -1.0, -0.5
  6. def ag(a, b):
  7. h1 = adim(w11 * a + w21 * b + b1)
  8. h2 = adim(w12 * a + w22 * b + b2)
  9. return adim(v1 * h1 + v2 * h2 + c)
  10. for a, b in [(0, 0), (0, 1),
  11. (1, 0), (1, 1)]:
  12. print(a, b, ag(a, b))
a
0
b
1
h1
1
h2
0
y
1