Conv_forward First test incorrect

Hello, I’m getting the following error below. I’m not sure how to go about debugging this one. If someone could give me a nudge in the right direction, I’d appreciate it. I find the all zeros baffling; I suspected a padding error, but my zpad function seems to work as expected.

Z’s mean =
0.5151827378782476
Z[0,2,1] =
[0. 0. 0. 0. 0. 0. 0. 0.]
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.5151827378782476

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. 0. 0. 0. 0. 0. 0. 0.]


AssertionError Traceback (most recent call last)
in
15
16 conv_forward_test_1(z_mean, z_0_2_1, cache_0_1_2_3)
—> 17 conv_forward_test_2(conv_forward)

~/work/release/W1A1/public_tests.py in conv_forward_test_2(target)
117 [-0.47552486, -0.16577702, -0.64971742, 1.63138295]])
118
→ 119 assert np.isclose(Z_means, expected_Z), f"Wrong Z mean. Expected: {expected_Z} got: {Z_means}"
120 assert np.allclose(cache_conv[0][1, 2], expected_conv), f"Values in Z are wrong"
121

AssertionError: Wrong Z mean. Expected: -0.5384027772160062 got: -0.2981759579224176

The most common problems here have to do with managing the stride. Note that the first test case has stride = 2. The loops are over the output space and we must touch every location there. The striding (skipping) happens only in the input space.

Thank you. I had a bad indentation in one of my for loops.

1 Like

It’s great news that you were able to solve this under your own power. Nice work and thanks for confirming. Onward! :nerd_face:

1 Like