/mnist-demo

An interactive demonstration of single digit classification using deep artificial neural networks

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

MNIST Demo

An interactive demonstration of single digit classification using deep artificial neural networks.

Two neural networks have been trained on the MNIST data set using the Google TensorFlow library.

  • A simple, fully connected 3 layer neural network, trained to a test accuracy of 91.8%.
  • A convolutional neural network, with 2 convolutional layers and a fully connected layer, trained to a test accuracy of 99.2%.

This web application demonstrates the ability of both networks to classify handwritten digits.

Demonstration

This application is available at mnist-demo.herokuapp.com

Once you draw an image it is scaled to the appropriate 28x28 pixel resolution and evaluated with both networks:

Demo

Code

Web

The front-end is a single page web application developed with the React and and Redux.js frameworks.

Server

The server is a python Flask server which uses Google's TensorFlow library to evaluation pre-trained neural networks for handwriting recogntion.

Neural Networks

Both the fully connnected and convolutional neural networks have been trained using TensorFlow and following the tutorials MNIST for ML beginners and Deep MNIST for Experts. The training data used are the 60,000 training images from the MNIST database of handwritten digits.

Getting Started

Requirements

Install Dependencies

Server Dependencies:

(Linux)

pip install -r requirements.txt

(Mac)

pip install -r requirements-mac.txt

Web Dependencies:

npm install

Run Application

To build and run the app locally run:

npm run build && npm run gunicorn

The app will be running at localhost:8000

Webpack front-end development server

To run the app with the front-end development server run:

npm run gunicorn
npm run dev

The development server will be running at localhost:8080 and proxying requests to localhost:8000

Neural Networks

The pre-trained neural networks are saved in the models directory.

To re-train the networks run:

python networks/fully_connected.py
python networks/convolutional.py

The trained networks will be saved to the /tmp directory

Deployment to Heroku

To deploy the application to Heroku, run the following:

heroku apps:create <NAME>
heroku buildpacks:add heroku/nodejs
heroku buildpacks:add heroku/python
git push heroku master

License

Released under GPLv3, see LICENSE.txt