Skip to content

niemenjoki/handwritten-digit-classification

Repository files navigation

Computer-Vision-Project

The purpose of this project was mostly to help me learn programming.

However, I encourage anyone to contribute to this project! See CONTRIBUTING

Dataset

To create the dataset, I coded and published a public web app, where anybody can draw digits. The app posts the pixel data and the label to a Google Cloud Firestore database I set up.

The web app is still online and submitted digits are still occasionally being added to the dataset.

The dataset has examples of handwritten digits. The data is in a JSON format. The file contains an array of objects, where each object has two fields:

  • image: a 784-element array of numbers [0,255], representing pixel values for each 28x28 handwritten image. 255 means white and 0 means black.
  • label:: the label for this character

The current amount of digits in the dataset (28 November, 2019):

All0123456789
13942 1284 1441 1439 1376 1431 1357 1374 1465 1328 1447

Picture of the dataset

Using the dataset

Anyone is free to do anything they want with the dataset. You can either download it or use it with AJAX. An attribution is appreciated but not required.

Download

You can download the data here

AJAX
let data;
(async () => {
  const URL = 'https://raw.githubusercontent.com/jnsjknn/handwritten-digit-classification/master/data/dataset.json'
  data = await fetch(URL).then(res=>res.json());
})()
// data becomes: Array(13942) [{...}, {...}, ..., {...}]

The neural network

For now, the neural network is an almost exact copy of the Coding Train's Toy Neural Network which uses stochastic gradient descent backpropagation. The neural network uses non-optimized functions which causes a lot of performance issues. Eventually, I may try switching to TensorFlow.js.

The neural network that is currently being used in the main app was trained with 60 epochs, each having 12547 digits from the dataset. Each digit was fed forward individually and the weights and biases were adjusted each time. Learning rate started at 0.01 and was divided by 2 every 5 epochs. Testing with the rest of the dataset (1392 digits), the network correctly predicted 77% of the labels.

Credits

This project was immensely inspired by Daniel Shiffman and particularily, his Neural Networks Playlist on Youtube on which my implementation is largely based on.

Thank you also to 3Blue1Brown for his Youtube playlist which greatly helped me understand neural networks.

Releases

No releases published

Packages

No packages published