Giter VIP home page Giter VIP logo

mnist's Introduction

MNIST

Practice with TensorFlow and Keras. Initial solution to MNIST problem. Many areas for improvement

My program is built with python3.6. Start virtual environment from inside project directory: source venv/bin/activate. Install dependencies: pip install -r requirements.txt. Once dependencies have been installed, you can run it like this:

To train: python main.py To predict: python main.py --predict Handwritten-digit-2.png

Training will save the architecture of the neural network as a JSON file and the weights at the end of training as a .h5 file. Predict loads these values from a default './model_architecture.json', and './model_weights.h5' locations. An area of improvement here could be a dynamic source and multiple saving and loading mechanisms. The input provided had extraneous text, so other examples were used. In the future, I would implement a region-of-interest algorithm so that the inputs do not have to be as clean.

Input -> Flatten -> Dense -> Dropout -> Dense -> output

My neural network is a keras sequential model which is a simple linear layer stack. I have four layers. This setup was chosen because it is a common layer stack and minimizes overfitting. Flatten is applied first in order to flatten input to a 28-d vector so that when Dense is called (the next layer) logits and labels have the same first dimension. Then a Dense layer of size n*n (784 neurons) with relu activation because relu because I usually start with a relu activation (fewer vanishing gradient problems). Then a dropout layer in the middle of the two major dense layers to avoid overfitting. Iā€™m pretty sure the way keras implements this is with the same number of neurons as the previous layer and a certain percentage (in this case 20%) activated. One more Dense layer with the size of the expected number of classes (10 neurons) and a softmax activation for simple probability resolution. Iā€™m constantly reaching 98% accuracy. With more time, I would loosen constraints on input type and implement online learning capabilities. My loss function is sparse categorical cross entropy because our targets are integers, I optimized with an adam optimizer and my metric was accuracy because of the project requirements.

mnist's People

Contributors

moonman312 avatar

Watchers

James Cloos 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.