Stack in the first programming exercise of course 4, week 1,graded function : 'conv_forward()'

Hello everyone,
I’m a little bit stack in the first programming exercise of course 4, week 1, graded function : ‘conv_forward()’. In fact the test keep telling me that the value I’m getting is incorrect (Z’s mean = 0.5511276474566768 instead of : 0.5329033220060434), I checked my code many times, I even rewrite the code from the beginning, but I can’t find the problem,

Try searching the forum for posts that contain “conv_forward”. You’ll find lots of material to study.

1 Like

This is the error :

Z’s mean =
0.5329033220060434
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

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]

I went through the fourm posts, but I can’t find helpful things, can I put my code here if you can make a look and help me. Cause I m stack in this for days.

Those wrong values are exactly what you get if you omit the stride in the computation of the `vert_start` and `horiz_start` values. In the first test case, the stride is 2. The way this works is that the loops are over the output space and we must touch every point in the output space. The striding operation happens in the input space: you use the stride to compute the starting point on each iteration.

I made that mistake on purpose and here are my outputs, which match yours exactly:

``````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] = -3.52289092000083
Z's mean =
0.5329033220060434
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