Neuron 101

A neural network from scratch / A network that reads digits

Türkçe

Plate53

Unit 5 · Topic 11 of 12

A network that reads digits

Medium, 8 min, 7 steps

input, 144 pixels
Keyboard: left and right arrows change the step, space plays and pauses.

Step 1 of 7 Drawing

Drawing

A digit drawing: a 12 × 12 grid with 40 cells filled. Tap a cell to fill or empty it; you can change the drawing as you like.

Open in Colab
  1. import json, math
  2. ag = json.load(open("agirlik.json"))
  3. w1, b1 = ag["w1"], ag["b1"]
  4. w2, b2 = ag["w2"], ag["b2"]
  5. x = [int(c) for s in cizim for c in s]
  6. h = [max(0, b1[j] + sum(
  7. w1[j * 144 + i] * x[i]
  8. for i in range(144)))
  9. for j in range(32)]
  10. z = [b2[k] + sum(w2[k * 32 + j] * h[j]
  11. for j in range(32))
  12. for k in range(10)]
  13. e = [math.exp(v - max(z)) for v in z]
  14. p = [v / sum(e) for v in e]
  15. print(p.index(max(p)))
tahmin
3
guven
100.00
noron
11
hn
12.15
dolu
40