Every weight, activation and gradient in this network was written by hand in NumPy. Draw a digit below and watch it think — live, in your browser.
Draw any digit from 0 to 9. The prediction updates in real time, with the model's confidence for every digit.
The app names a digit — you draw it. One point for every correct draw.
No mouse, no touch — your camera watches your hand. Pinch your thumb and index finger together to draw, separate them to lift the pen. The same network predicts.
Open Air WritingThree steps between your mouse and the answer — all of them implemented by hand.
Your drawing is shrunk to 28×28 pixels and centred by its centre of mass — exactly how the MNIST dataset was prepared, so the network sees what it expects.
784 pixel values flow through two hidden layers (128 and 64 neurons, ReLU). Every connection multiplies by a weight the network learned during training.
The output layer turns eleven scores into probabilities that sum to 1 — ten digits plus a “not a digit” class trained on scribbles, arrows and half-drawn shapes, so junk gets rejected instead of guessed.
Trained with hand-written backpropagation and mini-batch gradient descent on MNIST.
Gradients are computed with the chain rule, layer by layer, in plain NumPy — no autograd, no framework magic.
Weights start as small random values scaled by √(2/fan-in), keeping the signal stable through the ReLU layers.
Training loss fell from 0.201 to 0.032 over 12 epochs on 189,000 images — digits, augmented copies and 24,000 “not a digit” examples — while validation accuracy climbed to 98.56%.
Measured on the 10,000-image MNIST test set — images the network never saw during training.
Programming for AI (AIC270) — COMSATS University Islamabad, Attock Campus. Instructor: Ms. Fouzia Jabeen.
FA24-BAI-024
Network core + integration
FA24-BAI-032
Demo + interfaces
FA24-BAI-059
Testing + report
The things everyone asks about this project.
Because then the library would be doing the learning — and we would learn nothing. Writing the forward pass, the loss and backpropagation by hand is the whole point of the project; the demo is proof it works.
Not yet — by design. The same code can be retrained on EMNIST with a 36-unit output layer (10 digits + 26 letters). That is the documented next step, listed as future work in the report.
Very slanted, broken or unusually styled digits differ from MNIST handwriting. Centring helps, but a digit drawn in a corner or with gaps can still fool it — the confidence bars show when the model is unsure. Anything that is not a digit at all — a scribble, an arrow, half a shape — is rejected by a dedicated “not a digit” output it was trained on.
A second page where your webcam tracks your hand: pinch thumb and index finger together to draw in the air, separate them to lift the pen. The same network predicts. Try it from the button in the hero.
The full source, training notebook and project brain are open on GitHub.
View on GitHub