Creating the first fully connected layer
In this recipe, let's create the first fully connected layer.
Getting ready
The following are the inputs to the function defined in the recipe Using functions to flatten the densely connected layer, create_fc_layer:
Input: This is the flattened convolution layer; that is,layer_flatNum_inputs: This is the number of features created post flattening,num_featuresNum_outputs: This is the number of fully connected neurons output,fc_sizeUse_relu: This is the binary flag set toTRUEto incorporate non-linearity in the tensor
How to do it...
- Run the
create_fc_layerfunction with the preceding input parameters:
layer_fc1 = create_fc_layer(input=layer_flat, num_inputs=num_features, num_outputs=fc_size, use_relu=TRUE)
How it works...
Here, we create a fully connected layer that returns a two-dimensional tensor. The first dimension (?) represents any number of (input) images and the second dimension represents the number of output neurons (here, 1,024).