Here is a code snippet wherein I add two convolution layers one with 3x3 filter followed by a layer with 1x1 filter. While I am sure how the parameters are calculated for 3x3 filter, I could not figure out the learnable parameter calculation for 1x1 convolution. Could someone help me understand?
model = Sequential()
inputShape = (227, 227, 3)
model.add(Conv2D(32, (3, 3), padding="same",
input_shape=inputShape))
model.add(Conv2D(32, (1,1)))
Upon running model.summary()
, the output is like:
Model: "sequential_2"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d_5 (Conv2D) (None, 227, 227, 32) 896
_________________________________________________________________
conv2d_6 (Conv2D) (None, 227, 227, 32) 1056
=================================================================
Total params: 1,952
Trainable params: 1,952
Non-trainable params: 0
How did it arrive at 1056 parameters for the 1x1 convolution?
n_channels_in x n_channels_out = 32 x 32 = 1024
) and the number of biases (n_channels_out = 32
), which adds up to1056
. – Oxbowerce Jul 07 '21 at 16:16