Deep Learning web app

Source: Deep Learning on Medium

Model creation

First, let’s load the Mnist dataset provided by keras; then split it into training and validation sets, to verify that our model generalizes well after training:

In this dataset each sample is an image represented as a matrix of 28*28 pixels; each pixel having a value between 0 (black) and 255 (white). Let’s plot a few samples:

We then create a Convolutional Neural Network using tf.keras:

We choose a loss function (cross entropy), an optimizer (adam), and train the model:

GPU is warming up… Training took ~5 minutes with a NVIDIA GPU 1080.

During the training we can start a tensorboard server to pick up training stats and display it in nice graphs. To do so, run tensorboard — logdir=”C:\temp\tensorboard\”, then navigating to http://localhost:6006/:

Training stats (accuracy and cross loss) on training and validation sets.

Now let’s deploy our model as a service to accept prediction requests.