W1A1 conv_backward

I got the dA, db correct, but the dW doesn’t match the expectation. I got dW_mean = -0.30435376426377897 but expectation is 1.7269914. I can’t figure out what’s going wrong. Is there any correct solution I can refer to?

My implementation as below:

Mentor Edit: Solution Code Removed

Your code is almost correct. Just one correction: it is not necessary that w and h have the same values. So, [i, w, h, c] and [i, h, w, c] will give different results. Check the instructions again for the correct order.

Thanks. In graphic program we usually put width before height. But looks like the CNN tensor put the height before width. Lesson learnt.