AI Fundamentals
Chapter 10 · Recognizing Handwritten Digits

Train a digit reader

Choose the network, train it here in your browser on real MNIST digits, and test it on a digit you draw. Nothing is uploaded: the data and the training stay on this page. Just want to read a digit? Try the simple version, Read my digit.

1 Build the network

One hidden layer of 100: the model from Chapter 10.
Parameters (weights + biases): 79,510

One iteration (an epoch) is one pass over all the training digits. Like scikit-learn, training stops before max_iter when the loss improves by less than tol=0.0001 for 10 iterations in a row.

2 Train and test

Iteration–
Loss–
Test accuracy–
Loading 14,000 MNIST digits…

The confusion matrix for the test digits appears here after training. Random guessing would get about 10%.

Some training digits, with their labels

3 Try your own digit

?
Train a network, then draw a digit.

Your drawing is turned into what the network was trained on: 28 × 28, white digit on black, about 20 × 20 and centered.

Runs so far

Each training run is added here, so you can compare what changed. Best test accuracy in bold.

#Hidden layersNeuronsActivationmax_iterIterationsTraining digitsParametersTimeTest accuracy

No runs yet.

The same model in Python


  
  

The code changes as you change the settings above. This page trains with TensorFlow.js, the browser version of TensorFlow, on a random sample of MNIST (12,000 training and 2,000 test digits), or on the full MNIST set (60,000 and 10,000), the same digits as the MNIST CSV files. The full set downloads zipped and is unzipped by your browser.