Below is the tale of my pioneering journey into the world of neural networks. The goal of this project is to develop the code to create a deep learning neural network designed to classify images of hand-written digits. Although there are some great existing libraries with "ready-made" code for this problem (e.g. scikit-learn, tensorflow) my aim is to write everything mostly from scratch. I also hope to do a good enough job documenting the workflow to serve as a learning tool for any interested readers.
Before going on further I must acknowledge the superb educational/instructional video series from Grant Sanderson's YouTube channel 3Blue1Brown which layed the foundation for this project.
- About the Data
- About the Network
- Digit Canvas - Draw your own numbers and have the network guess them
- References
Training and testing data are taken from the well-known and widely-utilized MNIST database. This database includes a training set of 60,000 labeled images and a test set of 10,000 labeled images; however, because there are no intrinsic differences between the two you can think of it as one aggregate set of 70,000 images. Each image is 28x28 pixels in size and has been preprocessed to be centered in the field based on the "center of mass" of the pixel values (I learned this the hard way by trying to center the images myself only to find that it had already been done).
Here are a few examples of the images:
The neural network code is encapsulated in the NumberClassifier object.
It generates the infrastructure for a fully-connected neural network with an arbitrary number of hidden layers each containing an arbitrary number of neurons (Note: Convolutional NNs generally tend to do better with image classification, which I may explore as an extension of this project).
DigitCanvas is an interactive figure which allows you to draw your own numerals and have the network guess them.
The infrastructure for this figure is also encapsulated as an object (surprised?).
The interactivity is entirely handled my the mpl_connect method within matplotlib and several event classes (I found the official matplotlib documentation on this quite helpful).
First you'll need to clone the repository to your machine.
Next, open a terminal and switch to the code directory within it and execute the python script DigitCanvas.py.
git clone https://github.com/tomczak724/Number_Classification_Neural_Network.git
cd Number_Classification_Neural_Network/code/
python DigitCanvas.py
If all went well a figure like this should appear:
Simply use your mouse to draw your number of choice in the large square panel on the left.
Once you're finished click the SUBMIT button to have your drawing digitized, centered, and processed by the network to guess your digit. The panel to the lower-right will indicate the network's best guess as well as it's confidence in all 10 possible digits. Click the CLEAR button to reset.
3Blue1Brown - YouTube channel of excellent visual explainations of topics in mathematics
MNIST database - Puplic database of handwritten digits
matplotlib interactive events - Matplotlib's official documentation on event handling



