A neural network to classify handwritten numbers. The code is based off of this book by Michael Nielsen.
python -m venv .
source venv/bin/activate
pip install -r requirements.txt
The data are a part of the mnist module.
All data is taken from the MNIST dataset curated by Yann LeCun, Corinna Cortes, and Christopher J.C. Burges from this website.
Running python handwritingAI.py --train
will train the AI with the default number of layers (1 hidden layer with 10 nodes), a learning rate of 3 (eta = 3), and a mini-batch size of 10. After the training is finished, the AI's information will be saved in configs/config.conf
.
To use this default config file to predict against the test data, run python handwritingAI.py --predict
.
To do all of this all at once, run python handwritingAI.py --trian --predict
.
For a full listing of all options, run python handwritingAI.py -h
.
The program has support for displaying the images.
To display the first 100 images with matplotlib of the training dataset, run python handwritingAI.py -n 100 --train -d
.
To save that figure as an image, run python handwritingAI.py -n 100 --train -d --save-image image.png
.
Similarly, to display first 100 images with matplotlib of the test dataset, run python handwritingAI.py -n 100 --train -d
.
You can tell the program to color the images according to the how a particular AI configuration predicts the values, run python handwritingAI.py -c <config> -n 100 --train -d -C
.
To view the 100 images starting at the 1000th test (or training) image, run python handwritingAI.py -c <config> -n 100 --image-display-offset 1000 --predict -d -C
.
- Inspired by this blog.
- Program design followed from reading this online textbook http://neuralnetworksanddeeplearning.com/chap1.html.