0
$\begingroup$

I was asked this question: Given an image with shape [1,28,28], what will be the shape of the output of a convolution layer with 10 5x5 kernels (filters) without padding?

Now, are the shape dimensions [row, column, depth]? I really don't understand how you apply a 5x5 kernel on such image, because its 1x28...

What am I missing here?

$\endgroup$

2 Answers 2

1
$\begingroup$

The order of dimensions usually depends on the library you are using

Tensorflow : (Height,Width,Channel) : HWC

PyTorch: (Channel,Height,Width) : CHW

In your case the image seems to go with CHW , since you cant apply 5x5 filters on a 1x128 image

As for the final shape , we follow the rule :

for input length N, and k-size filter , output-length = N-k+1

so each of the 10 filters produces output length = 28-5+1 = 24

so output length = (10,24,24) in the CHW format

Here is a simple Tensorflow code to test it if you want :

from tensorflow.keras.layers import Input,Conv2D
x = Input(shape=(28,28,1))
x = Conv2D(filters = 10, kernel_size = 5, padding='valid')(x)
print(x.shape)
$\endgroup$
0
$\begingroup$

The image dimensions can either be CHW (Channel, Height, Width) or HWC (Height, Width, Channel). In this case, the image dimensions appear to be CHW, and so you're possibly looking to apply a 5x5 kernel to a 28x28 image.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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