Step 6 – Creating a CNN model

Now we have the input; that is, x_image is ready to feed to the convolutional layer. We formally create a convolutional layer, followed by the max pooling:

layer_conv1, weights_conv1 =  
    LayersConstructor.new_conv_layer(input=x_image, 
                   num_input_channels=num_channels, 
                   filter_size=filter_size1, 
                   num_filters=num_filters1, 
                   use_pooling=True) 

We must have the second convolutional layer, where the input is the first convolutional layer, layer_conv1, followed by the max pooling:

layer_conv2, weights_conv2 =  
    LayersConstructor.new_conv_layer(input=layer_conv1, 
                   num_input_channels=num_filters1, 
                   filter_size=filter_size2, 
                   num_filters=num_filters2, 
                   use_pooling=True) 

We now have the third convolutional layer where the input is ...

Get Practical Convolutional Neural Networks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.