Skip to content

Self-made Neural Network to classify handwritten numbers

Notifications You must be signed in to change notification settings

K20shores/handwritingAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

handwritingAI

A neural network to classify handwritten numbers. The code is based off of this book by Michael Nielsen.

Setup environment

python -m venv .
source venv/bin/activate
pip install -r requirements.txt

Data

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.

Run

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.

Viewing the Images

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.

training images

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.

predicted values

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. predicted values starting at the 1000th test image

Resources used to make thie AI.

About

Self-made Neural Network to classify handwritten numbers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages