A four-layer network with about seventeen thousand weights, trained from random noise to reading handwriting in the few seconds it took this page to load. Nothing is pre-trained and nothing is faked: the forward pass, the ReLU, the softmax, the cross-entropy gradient and the Adam optimiser are all written out in this file. Draw a digit in the box and the network votes on all ten classes as you move the mouse. This is the Deep Learning layer, where depth and a lot of parameters replace hand-designed features.
browser version uses a 64→128→64→10 dense network on 8×8 images in place of a convolutional net on 28×28 MNIST — same pipeline (downsample, normalise, forward, softmax, argmax), smaller engine. Training data is 400 samples from scikit-learn's load_digits, inlined as a compressed string.
initialising…
tap an example, or clear it and draw your own
Your 280-pixel drawing is averaged down to sixty-four intensity values, the same resolution and scale the training images use. Everything the network knows about your digit is in that little grid.
Four hundred labelled 8×8 grayscale digits are embedded in this page as a string, one character per pixel, exported offline from scikit-learn's handwritten-digits dataset. On load, the pixels are scaled to the zero-to-one range and fed to a dense network of two hidden layers using ReLU activations, with a ten-way softmax on top and cross-entropy as the loss, trained by minibatch Adam for a few hundred epochs inside animation frames so the tab never freezes. Backpropagation is written out by hand: the softmax and cross-entropy gradient collapses to predicted-minus-target, which then flows back through each weight matrix, zeroed wherever a ReLU was inactive. When you draw, the canvas is box-averaged from 280 pixels down to 8×8, giving each cell the mean ink in its patch, then rescaled to match the brightness range of the training data. That vector runs through the same forward pass, and the softmax output is exactly the ten bars on the right.