Need help with conv_forward

please help me with conv_forward function
IndexError Traceback (most recent call last)
in
6 “stride”: 2}
7
----> 8 Z, cache_conv = conv_forward(A_prev, W, b, hparameters)
9 z_mean = np.mean(Z)
10 z_0_2_1 = Z[0, 2, 1]

in conv_forward(A_prev, W, b, hparameters)
81 W_sliced=W[:,:,:,c]
82 b_sliced=b[:,:,:,c]
—> 83 Z[i,h,w,c]=conv_single_step(a_prev_pad,W_sliced,b_sliced)
84 # YOUR CODE ENDS HERE
85

IndexError: index 4 is out of bounds for axis 2 with size 4

latest output:
Z’s mean =
0.13271959100960323
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: Z’s mean is incorrect. Expected: 0.5511276474566768
Your output: 0.13271959100960323 . Make sure you include stride in your calculation


ValueError 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)
85 b = np.random.randn(1, 1, 1, 8)
86
—> 87 Z, cache_conv = target(A_prev, W, b, {“pad” : 3, “stride”: 1})
88 Z_shape = Z.shape
89 assert Z_shape[0] == A_prev.shape[0], f"m is wrong. Current: {Z_shape[0]}. Expected: {A_prev.shape[0]}"

in conv_forward(A_prev, W, b, hparameters)
81 W_sliced=W[:,:,:,c]
82 b_sliced=b[:,:,:,c]
—> 83 Z[i,h,w,c]=conv_single_step(a_prev_pad,W_sliced,b_sliced)
84 # YOUR CODE ENDS HERE
85

in conv_single_step(a_slice_prev, W, b)
23 # Z = None
24 # YOUR CODE STARTS HERE
—> 25 s=np.multiply(a_slice_prev,W)
26 Z=np.float64(np.sum(s)+b)
27

ValueError: operands could not be broadcast together with shapes (2,2,4) (3,3,4)

Have you searched the forum for posts containing “conv_forward”? There are lots of previous questions about this assignment.

yes, i have searched

Does your conv_single_step() pass all its tests in the notebook?

If not, did you follow all of the instructions for conv_single_step()?:

    # Element-wise product between a_slice_prev and W. Do not add the bias yet.

    # Sum over all entries of the volume s.

    # Add bias b to Z. Cast b to a float() so that Z results in a scalar value.

i found the solution, thank you