Neural Network for Handwritten Digits




This is a university project that uses a neural network to recognize handwritten digits. Try it out by drawing a digit (0 to 9) in the box above and see if the network can guess which one you drew!


How it works

As you are drawing an image above, the network is constantly analyzing it (about 60 times every second) and "guessing" what digit you are drawing. To do this, your image is resized to 28x28 pixels and then given to the network. The resized image (shown alongside the original) represents how the network sees your drawing.

Each time the network looks at your drawing, it will decide how much it looks like each digit (0 - 9). This is represented by the bars above labeled 0 through 9, which show how confident the network is that you drew that number. So for example, if the network is pretty sure that you are drawing a '3', the bar labeled '3' above will be much larger than the other bars.


The network was trained using the MNIST database. The MNIST database is a large collection of handwritten digits, which were collected from high school students and Census Bureau employees. It consists of 60,000 images for training and 10,000 images for testing. A sample of what these images look like is shown below. You can find out more on the MNIST Database Website.


When asked to classify all 60,000 training digits in the MNIST database, the network is about 86% accurate. For images that I've drawn, it's right about 75% of the time. This obviously isn't ideal, and couldn't be used in the real world (eg. automatically process checks at a bank). Regardless, I think it's a good first step for entering the world of neural networks, and I'm excited to improve this version in the future.


I used a NodeJS server to create and train the network. The learned values of the network were saved in a json file so they could be used later. The interface you see here was created using standard web tools (jquery/js/css/html). There are some serious limitations when using javascript for a project like this (mainly speed), but I chose it anyways. The main reason is that I wanted to have a live demo for people to try, and a web-based version let me do that quickly and easily with no issues.

For source code, visit the github page for this project.