Neural Network
from Scratch
A handwritten digit classifier implemented in Python and NumPy.
Draw a digit
28 × 28One digit, 0–9. Mouse or touch.
Loading the trained model…
Prediction
Draw a digit, then make a prediction.
Output scores for digits 0-9. Hand-drawn inputs may differ from MNIST.
See the model’s input
Drawings are scaled and centered before prediction.
How the network learns
Forward propagation, ReLU, loss, backpropagation, and a weight update.
Loading a labeled example...
1 / 9
Input
Each grayscale pixel is divided by 255 to form 784 input values.
x = pixel / 255
Implementation
This started with wanting to understand how neural networks learn. Inspired by 3Blue1Brown’s neural network series, I implemented the network in Python and NumPy, including forward propagation, backpropagation, and gradient descent.
It takes a 28 × 28 grayscale image and predicts a digit from 0 to 9. Building it helped me connect the matrix operations to what the network is actually doing.
10,000 held-out MNIST images
Retrained from my original implementation on 60,000 training images: 500 full-batch iterations, learning rate 0.1, seed 42. My original project reported 92.16%. This demo runs the newly saved weights entirely in your browser.
View on GitHub