How it works...

The functionality is as follows:

  1. By using the sequential function, a nine-layer convolutional neural network is defined with each layer performing the following functions:
    1. The first layer is a convolutional layer with 16 neurons and performs convolution on the input tensor/matrix. The size of the feature map is defined to be a 3 x 3 matrix. The input shape needs to be specified for the first layer since the neural network needs to know what type of input to expect. Since all the images have been cropped to a size of 128 x 150 pixels, this will be the input shape defined for the first layer of the network as well. The activation function used in this layer is a rectified linear unit (relu).
    2. The second layer of the network ...

Get Apache Spark Deep Learning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.