Source: Deep Learning on Medium
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:
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/:
Now let’s deploy our model as a service to accept prediction requests.