In: Computer Science
Consider a Convolutional Neural Network which accepts a 120 x
120 CMYK image as input.
The network has a series of 5 convolutional layers, where the
parameters in conv-layer 3 and
conv-layer 5 are shared. Each conv-layer has 20 3x3 filters. The
output of the last conv-layer is
flattened and passed through a fully connected layer with 30
neurons, which is then passed
through another fully connected layer of 10 neurons. Each neuron in
the fully connected layers
and each filter in the conv-layers also have a scalar bias
associated with them, which are also
trainable parameters. Calculate the total number of trainable
parameters in the network. Show
your calculation.
Solution
Calculating the parameters without dropouts:
The input_1(Input Layer) has shape (None,120,120,1) and parameter is 0. In the whole program stride=1,kernel_size=3*3,padding=same and filters =20.
Convolutional_1 : ((kernel_size)*stride+1)*filters) = ((3*3)*1+1)*20 = 200 parameters. In first layer, the convolutional layer has 20 filters.
Convolutional_2 : As convolutional_1 already learned 20 filters. So the number of trainable parameters in this layer is ((3 * 3) * 20 + 1) * 20 = 3,620 and so on.
Max_pooling_2d_1: This layer is used to reduce the input image size. kernal_size = (3,3) used here. So input image 120 is reduced to half 60. And model learns nothing from this layer.
Convolutional_3 : ((3 * 3 * 20 + 1) * 40) = 7,240 and so on.
Convolutional_4 : similarly for this , it is ((3* 3 * 20 + 1) * 40) = 7,240 and so on.
Max_pooling_2d_2: This layer is used to reduce the input image size. kernal_size = (3,3) used here. So input image 60 is reduced to half 30. And model learns nothing from this layer.
Convolutional_5 : Finally in this layer, it is ((3* 3 * 20 + 1) * 80) = 14,480 and so on.
At last all parameters sum together.
Total Training Parameter =32,780
Trainable Parameters = 32,780
Non-Trainable Parameter = 0.
Hence the total number of parameters are 32,780
if you have
any Queries Please comment below
if you like my answer please upvote / like it.
Thank you