Shape of the filter used to convolve

when we do backprop convolution the shape of the filter comes out to be 2x2 which has three layers and 8 such filters are used according to the code .
W = np.random.randn(2, 2, 3, 8)
f , f, n_C_prev , n_C = W.shape

but when i compare the output it is some how
3x8 the size of filter with 2 layers and 2 such filters are being used .

can anyone explain what am i missing ?

I think you are just misinterpreting the way the “print” statement works with 4D arrays. That picture does show a 2 x 2 x 3 x 8 array. Notice that there are 4 “chunks”, each of which is 3 x 8. Then look at how the second and third level of the square brackets groups them. That’s just how it looks, because is “unwinds” things from the highest dimension first. It’s clear from the test code that the shape is 2 x 2 x 3 x 8. You can write your own print function to make the structure more clear, if you don’t believe my interpretation of the print out.

so you agree there are two blocks , each of which has 3x8 dimesnional array , and there are two such blocks .

My question is kernel size should have been 2X2 , rather than 3X8 , tha value of fxf should be 2x2 .

by code if we unwind w.shape = f should be 2
n_C_prev = 3
n_C =8

but when i see the output it is some something to my understanding 3x8 becomes the kernel size and 2 such kernels are used for each convolution.

it would be very helpful if you can explain more a bit . i think you have understood where i am going wrong . your help is deeply appreciated .
thanks .

Please read what I said in my first reply again: you are simply misinterpreting the output of the print statement that you are seeing. As I said that array is 2 x 2 x 3 x 8. So what is the problem here?

You can see the logic in the test block that generates the W array. Or add a print statement like this to your code to confirm what I am saying:

print(f"W.shape = {W.shape}")

1 Like