NETWORK

In this post I'll show how to prepare Docker container able to run already trained Neural Network (NN). It can be helpful if you want to redistribute your work to multiple machines or send it to a client, along with one-line run command. Sample code is using Keras with TensorFlow backend.

Prerequisites

  1. Already prepared Keras NN. We'll save it to HDF5 file (here you can find more info).
  2. Docker installed (instructions)

Code

For simplicity, we'll be using using well known example - CIFAR10 classification.

Firstly, we have to train our model and save it for later use. Here I'll show just relevant fragment - how to save model to .h5 file, because you probably have your own code that you want to distribute. Note that we probably want to run this in the cloud or on a computer with a good GPU card, so we don't need to wait a lot: