Flattening the second convolution layer
In this recipe, let's flatten the second convolution layer that we created.
Getting ready
The following is the input to the function defined in the recipe Creating the second convolution layer, flatten_conv_layer
:
Layer
: This is the output of the second convolution layer,layer_conv2
How to do it...
- Run the
flatten_conv_layer
function with the preceding input parameter:
flatten_lay <- flatten_conv_layer(layer_conv2)
- Extract the flattened layer:
layer_flat <- flatten_lay$layer_flat
- Extract the number of (input) features generated for each image:
num_features <- flatten_lay$num_features
How it works...
Prior to connecting the output of the (second) convolution layer with a fully connected network, in step 1, we reshape the four-dimensional convolution layer into a two-dimensional tensor. The first dimension (?) represents any number of input images (as rows) and the second dimension represents the flattened vector of features generated for each image of...