Git Product home page Git Product logo

mnist-digit-classification's Introduction

mnist-digit-classification

Classifying images in the MNIST database for handwritten digits using the TensorFlow library with Python.

Models

conv2d model

The conv2d model consists of four pairs of conv2d-max_pooling2d layers connected to two dense layers, each with 512 nodes. The output of the last dense layer is normalized such that the output of each node lies in between -1 and +1. The normalized output is fed into the output layer (dense, 10 nodes) which applies a sigmoid activation function. The argmax of the activated outputs of the output layer is deemed as the predicted digit.

This model was trained for 100 epochs and achieved an accuracy of 99.32% on the test image dataset.

Examples

Correct classifications 4 0 1 8 7
Predicted 4 0 1 8 7
Confidence 100.00% 100.00% 100.00% 100.00% 100.00%
Actual 4 0 1 8 7
Incorrect classifications 6 0 8 2 5
Predicted 0 8 2 0 3
Confidence 79.08% 30.70% 98.27% 87.85% 91.36%
2nd best prediction 6 6 8 2 5
Actual 6 0 8 2 5

The second best prediction is simply the argmax of the output with the initial prediction ignored.

The model has a very high accuracy because it can successfully recognize features such as edges and shapes, and use them to come to a conclusion. The misclassifications are mainly skewed, rotated, or otherwise abnormal (ie: Misclassification #4).

To improve accuracy, the images can be cleaned up (rotation, skew correction, growth/decay of pixels towards the average*, etc.) before they are provided to the network during both training and testing.

* This would help by normalizing images where the numbers are too narrow or bold

Flat model

The flat model consists of a simple feedforward neural network with 8 layers. The input layer contains 784 nodes which represent the flattened image of a handwritten digit. The output layer consists of 10 nodes and the argmax of the output layer is deemed as the predicted digit.

This model was trained for 100 epochs and achieved an accuracy of 97.46% on the test image dataset.

Examples

Correct classifications 5 2 0 6 4
Predicted 5 2 0 6 4
Actual 5 2 0 6 4
Incorrect classifications 1 5 0 8 8
Predicted 7 8 2 2 7
Actual 1 5 0 8 8

Although the model has a relatively high accuracy, it fails to generalize well and misclassified some images that are easily legible due to the structure and approach to the problem (flattening the image).

mnist-digit-classification's People

Contributors

agojiya avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.