Week1 Prog Assignment 1 Exercise 3

There’s an error in the mean in the conv_forward() function. I have checked some previous threads on this exercise and I’ve tried matching my process with theirs but I can’t find anything different or wrong in my logic. Can anyone help?

I added some print statements in my code and here’s what I see from the first test case for conv_forward:

stride 2 pad 1
New dimensions = 3 by 4
Shape Z = (2, 3, 4, 8)
Shape A_prev_pad = (2, 7, 9, 4)
Z[0,0,0,0] = -2.651123629553914
Z[1,2,3,7] = 0.4427056509973153
Z's mean =
 0.5511276474566768
Z[0,2,1] =
 [-2.17796037  8.07171329 -0.5772704   3.36286738  4.48113645 -2.89198428
 10.99288867  3.03171932]
cache_conv[0][1][2][3] =
 [-1.1191154   1.9560789  -0.3264995  -1.34267579]
First Test: All tests passed!

Interestingly your Z[0,2,1] values and your cache_conv values agree, but the Z mean is wrong there as well.

The most common mistakes here are in handling the stride. Note that it is 2 in this test case and that the stride applies in the input space (A_prev), not in the output space (Z), right?

1 Like

I did an absolutely foolish mistake. I didn’t take the loop for w(horizontal start and end) inside the loop for h(vertical).
Thanks for replying​:blush:

It’s great news that you were able to find the problem under your own power. Lots more interesting material ahead. Onward! :nerd_face:

1 Like