mnist-coreml

Simple convolutional neural network to predict handwritten digits using Keras + CoreML for WWDC '18 scholarship [Accepted]

MIT License

Stars
49

MNIST + CoreML

Simple convolutional neural network to predict handwritten digits using Keras + CoreML built for WWDC '18 scholarship submission [Accepted]

What is a Convolutional Neural Network ?

A convolutional neural network is a class of deep, feed-forward artificial neural networks that have successfully been applied to analyzing visual imagery.

They were inspired by biological processes in that the connectivity pattern between neurons resembles the organization of the animal visual cortex. Individual cortical neurons respond to stimuli only in a restricted region of the visual field known as the receptive field. The receptive fields of different neurons partially overlap such that they cover the entire visual field.

From Wikipedia


Watch the full video on YouTube by Denis Dmitriev


The MNIST Dataset

The MNIST database is arguably the most famous database in the field of machine learning; it is a large database of 28x28 pixel images of handwritten digits created in 1999 by Yann LeCun.


The Model

Our model consists of 12 layers:

  1. Input (28x28 pixel image)
  2. Conv2D (Relu activation)
  3. MaxPooling2D
  4. Conv2D (Relu activation)
  5. MaxPooling2D
  6. Conv2D (Relu activation)
  7. MaxPooling2D
  8. Dropout (0.3)
  9. Flatten
  10. Dense
  11. Dropout (0.4)
  12. Dense (Softmax activation)

Draw and classify digits in Playground Canvas

Run the MNIST+CoreML.playground on Xcode 9.0+ or Swift Playground app on the iPad

Make sure disable Enable Results before running


Creating and Training The Model

The model was created and trained using Keras (a high-level neural networks API, written in Python)

Run the Jupyter notebook to train the network on your own device


Converting to CoreML

Core ML is a framework introduced by Apple at WWDC '17 to integrate machine learning models into iOS, tvOS, macOS and watchOS apps.

The coremltools python package makes it very easy to generate the .mlmodel file, then all you need to do is just drag and drop that file into your Xcode project and you're all set


Credits and Thanks


Contributing

Your feedback is always appreciated and welcomed. If you find a bug in the source code, you can help me by submitting an issue. Even better you can submit a Pull Request with a fix :)


License

This project is released under the MIT License