Error in Course 4 Week 1 Exercise 3 -conv_forward

My code seems right but I still get this error…anyone can help me please?

ValueError: operands could not be broadcast together with shapes (2,3,9) (3,3,4)

let me see how you calculated the corners

First of all, You have a problem in initializing Z, you should initialize Z with the new dimensions n_W and n_H not the previous ones.
secondly, I do not think this is the correct way to select the ith training example for a_prev_pad as m is the first dimension not the last one.
Try those hints and your code will work, hopefully :slight_smile:

1 Like

Is this code correct?

should be.
Did it work for you ?

It’s closer but the last dimension of Z is still wrong. You’ve set it to the number of input channels. It should be the output channels, right?

Also note that W and b are 4D arrays. When you index them to select the appropriate value based on the current output channel, you need 4 index values. You had this right in the earlier code, but broke it in the most recent version.

Also please note that we aren’t supposed to leave source code for the solution sitting around on the forums or in any other public place. Once you get this working, please edit your posts to remove the code. Thanks!

1 Like

Thank you for your help!

Oh you’re right. It’s work. Thank you!
Ok I am deleting the source code right now.

1 Like

Thanks for removing the source code! Glad to hear that you have everything solved now. Onward! :nerd_face: