Week1|conv_forward function

In programming assignment 1, for the conv_forward function, I get the following error. The previous functions have no errors.

Z's mean =
Z[0,2,1] =
 [-0.05723279  0.03991888 -6.24285862  0.53960581 -5.04059676  6.96991358
  3.69509379 -0.20955895]
cache_conv[0][1][2][3] =
 [-1.1191154   1.9560789  -0.3264995  -1.34267579]
First Test: Z's mean is incorrect. Expected: 0.5511276474566768 
Your output: 0.5329033220060434 

First Test: Z[0,2,1] is incorrect. Expected: [-2.17796037, 8.07171329, -0.5772704, 3.36286738, 4.48113645, -2.89198428, 10.99288867, 3.03171932] 
Your output: [-0.05723279  0.03991888 -6.24285862  0.53960581 -5.04059676  6.96991358
  3.69509379 -0.20955895] 

Second Test: All tests passed!

My code is as follows.

(Solution code removed by staff, as posting it publicly is against the honour of conduct)

I’m a little lost as to what the error is and why is it only affecting a single example. Any feedback is very much appreciated. Thank you.

Hi @cynic,

Firstly, please know that posting solution code publicly is against the honour code of our community. You can post your errors.

In cases when it would be required to look at your code, one of the mentors will specifically ask you to share it with them in a DM.

As for your mistake, your calculations of vert_start , vert_end , horiz_start , horiz_end are incorrect. You are not taking into account the “output layer’s indices” in those calculations, as mentioned in the Additional Hints section of that exercise.


@mubsi Thank you, and apologies for the mishap in the post.

I am facing the same problem but could not make out from the above discussion. Can anyone help me?

Please click my name and message your notebook as an attachment.

@vivek_mehta Please make use of stride when calculating the vertical and horizontal bounds for a_slice_prev.