Giter Club home page Giter Club logo

algorithm_02's Introduction

Handwritten Digit Recognition with TensorFlow

This repository is a part of Algorithm 02 Assignment; the original repository is Jin0316/Algorithm.

You can check out the (edited) notebook at /TensorFlow_mnist_example.ipynb; use nbviewer if GitHub viewer does not work.

The Models

I used the three models provided as examples as-is, stored as model1, model2, and model3 respectively.

Model definition and declaration.

def select_model(model_number):
    if model_number == 1:
        model = keras.models.Sequential([
                    keras.layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)),    # layer 1 
                    keras.layers.MaxPool2D((2, 2)),                                                 # layer 2 
                    keras.layers.Flatten(),
                    keras.layers.Dense(10, activation='softmax')])                                  # layer 3

    if model_number == 2:
        model = keras.models.Sequential([
                    keras.layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)),    # layer 1 
                    keras.layers.MaxPool2D((2, 2)),                                                 # layer 2
                    keras.layers.Conv2D(64, (3, 3), activation='relu'),                             # layer 3 
                    keras.layers.MaxPool2D((2, 2)),                                                 # layer 4
                    keras.layers.Flatten(),
                    keras.layers.Dense(10, activation='softmax')])                                  # layer 5
                    
    if model_number == 3: 
        model = keras.models.Sequential([
                    keras.layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)),    # layer 1
                    keras.layers.MaxPool2D((2, 2)),                                                 # layer 2
                    keras.layers.Conv2D(64, (3, 3), activation='relu'),                             # layer 3
                    keras.layers.Conv2D(64, (3, 3), activation='relu'),                             # layer 4
                    keras.layers.MaxPool2D((2, 2)),                                                 # layer 5
                    keras.layers.Conv2D(128, (3, 3), activation='relu'),                            # layer 6
                    keras.layers.Flatten(),
                    keras.layers.Dense(10, activation='softmax')])                                  # layer 7
    
    return model

model1 = select_model(1)
model2 = select_model(2)
model3 = select_model(3)

The summary() call reveals that each model has 54,090, 34,826, and 134,730 trainable parameters respectively; I expected that model with more trainable parameters would be more accurate in general.

Training

Each model was tranied with the same training images and labels from the MNIST dataset with 5 epochs.

Training results.

After the last epoch,

  • Model 1's accuracy and loss was 0.9834 and 0.0568.
  • Model 2's accuracy and loss was 0.9868 and 0.0429.
  • Model 3's accuracy and loss was 0.9907 and 0.0313.

Test Result

Each model was then tested with the same testing images and labels from the MNIST dataset.

Test results.

  • Model 2 was the most accurate one, with accuracy 0.9857 and loss 0.0517.
  • Model 3 follows with accuracy 0.9792 and loss 0.0657.
  • Model 1 was the least accurate, with accuracy 0.9682 and loss 0.1430.

This result disproves my former hypothesis where more trainable parameters meant more accuracy.

Images That Were Correctly Predicted

Each model predicted the first fifteen images similarly, with almost perfect confidence for each image.

Model 1's predictions. Model 2's predictions. Model 3's predictions.

Images That Were Incorrectly Predicted

Each model produced 318, 143, and 208 mispredictions; the first ten examples for each follows.

Ten incorrect predictions for each model.

algorithm_02's People

Contributors

eatchangmyeong avatar

Watchers

 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.