Skip to content

Image classifier written in javascript using the MNIST database of handwritten digits

Notifications You must be signed in to change notification settings

Firlej/MNIST-image-classifier

Repository files navigation

MNIST handwritten digits classifier

Handwritten digits classifier using a fully-connected neural network implemented in JavaScript and trained using the MNIST database of handwritten digits.

Usage

  • git clone https://github.com/Firlej/MNIST-image-classifier
  • cd MNIST-image-classifier
  • gunzip data_train.js.gz data_test.js.gz data_min.js.gz

Structure

It's all written in pure JavaScript without any libraries except the one I developed myself oskar.js. The library constains a Matrix class, which has all the essential methods, a neural network needs. On top of that I built Layer class which in turn is used by the NeuralNetwork class that wraps all the structures.

Initialising the neural network

I've implemented the neural network so you specify any number of hidden layers, with any number of neurons in each layer.

let nn  =  new  NeuralNetwork(784, [40, 40], 10);

There are three parameters. The number of input neurons, an array of numbers which represent the number of neurons for each hidden layer, and the number of output neurons.

Visualisation of the NN learning

Visualisation of the net learning. Weights are being constantly improved and the network's accuracy reaches ~96% after training.

Weights of a single neuron in the first hidden layer

This gif visualises the weights between the input layer and one of the neurons in the first hidden layer.

Acknowledgements

About

Image classifier written in javascript using the MNIST database of handwritten digits

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published