Course 4, Week1, conv_forward

I’ve been looking at this problem for a looong time and I can’t find my error. This is for the conv_forward function (week 1). I’m not sure what I’m doing wrong. Here’s my error message:

Z's mean =
 -0.09726298936646298
Z[0,2,1] =
 [-2.17796037  8.07171329 -0.5772704   3.36286738  0.          0.
  0.          0.        ]
cache_conv[0][1][2][3] =
 [-1.1191154   1.9560789  -0.3264995  -1.34267579]
(2, 13, 15, 8)
Error: Wrong output for variable in position 0.
 2  Tests passed
 1  Tests failed

Probably the one uncertainty I had was iterating over n_C versus n_C_prev or f in the last loop but I get a similar error regardless of what I tried. I know the most common error is accounting for stride in vert_start and horiz_start but that does not seem to be my issue here. I sincerely appreciate any help!

Your first four Z values are correct. The rest (the zeros) are not.
That is also why your Z’s mean value is wrong.
Everything else is OK.

Thank you Tom. I sincerely appreciate the feedback. I’ve done another correction where I looped over n_C . That replaces the last 4 zero values I had previously with other values. However, I’m still not passing.

Z's mean =
 0.297331243446856
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]
(2, 13, 15, 8)
Error: Wrong output for variable in position 0.
 2  Tests passed
 1  Tests failed

If I’m getting the first four values correct, it seems like my bug would be confined to the last loop, but I think I’ve explored the space of how I could be wrong. I’ve looked at this problem for many hours now. Would it be somehow possible to share my code privately to you?

(edited my reply. . . . . . )

Thank you so much! I’ll message you.

For those who may find this thread later:

Be sure your for-loops iterate over the correct range of values.

Yes, I had a silly error where my test cell was looping over the right variable but not in the actual function. Thanks again for your help @TMosh !

I am getting the same exact result and error thrown as ben_slacker did in 2021. Can anyone advise on what might be wrong w/ my code?

resolved. I had a n_H in one too many places. :slight_smile:

1 Like