0
$\begingroup$

I have a very basic question, but I couldn't get the idea about 2D convolution in Keras. If I would create a model like this :

model = tf.keras.Sequential([tf.keras.layers.ZeroPadding2D(padding=(3,3), input_shape=(64,64,3)),
                             tf.keras.layers.Conv2D(filters=1, kernel_size=(7,7))])

why the output shape is (None, 64, 64, 1) :

Layer (type)                 Output Shape              Param #   
=================================================================
zero_padding2d_63 (ZeroPaddi (None, 70, 70, 3)         0         
_________________________________________________________________
conv2d_67 (Conv2D)           (None, 64, 64, 1)         148       
=================================================================
Total params: 148
Trainable params: 148
Non-trainable params: 0

and not (None, 64, 64, 3) with 148 parameters?
As far as I understand, the 2D convolution is not a volume convolution, the window is a 2D-matrix, but not a 3D-cube, so could somebody please explain why do I have 64, 64, 1 instead of 64, 64, 3?

$\endgroup$
0
$\begingroup$

Your understanding is not correct.

The 2D convolution is indeed a volume convolution. The filter is a tensor of dimensions 7x7x3. The depth of the output equals to the number of filters in the convolution; yours has 1 filter, so the depth of the output is 1.

$\endgroup$
1
  • $\begingroup$ Thank you for clarifying! $\endgroup$
    – user52219
    Sep 7 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.