Week1 A1: conv_forward dimension relating to previous Channel

Hi I am working on conv_forward function, and consistently fail to match the dimensions required for element wise multiplication. I look up already posted questions, and it seems that slicing seems to work fine on my case, (3,3) in both cases. But I loose the third dimension in the a_slice_prev, while the weights have this third dimension. I thought this is the previous # of channels so I am confused now how it is necessary in calculation of the weights.

I also tried to slice the weights further with c, but I know this is weird because I use channel number for both previous # channels and current # of channels.

And then, I explored without slicing a_slice_prev using c, to retain the third dimension. But they it started to mess up the slicing part.

Do you have any idea what is going on here? This chunk of code has been challenging for me…

The slicing should use [:, :, :, c].
The β€˜:’ characters are a wild-card match for all index values in that dimension.

1 Like

Thank you for the suggestion. It took me a while to figure out the issue here. But it worked in the end. Thank you so much!

1 Like