Training a convolutional neural network in Keras
Now that we've covered the fundamentals of convolutional neural networks, it's time to build one. In this case study, we will be taking on a well-known problem known as CIFAR-10. This dataset was created by Alex Krizhevsky, Vinod Nair, and Geoffrey Hinton.
Input
The CIFAR-10 dataset is made up of 60,000 32 x 32 color images that belong to 10 classes, with 6,000 images per class. I'll be using 50,000 images as a training set, 5,000 images as a validation set, and 5,000 images as a test set.
The input tensor layer for the convolutional neural network will be (N, 32, 32, 3), which we will pass to the build_network
function as we have previously done. The following code is used to build the network:
def build_network(num_gpu=1, input_shape=None): inputs = Input(shape=input_shape, name="input")
Output
The output of this model will be a class prediction, from 0-9. We will use a 10-node softmax
, as we did with MNIST. Surprisingly, nothing changes in...