C4W1 A1 exercise 3 - conv_forward()

Hi, I am working with the conv_forward() function and have read all the related threads about possible errors including stride in vert and horiz starts, parenthesis, aprev_pad instead of a_prev etc. but still hav’nt solved my issue


ValueError 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)
94 weights = W[:,:,:,c]
95 biases = b[0,0,0,c]
—> 96 Z[i, h, w, c] = conv_single_step(a_slice_prev, weights, biases)
97
98

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.sum(s)
27 Z = Z + np.float64(b)

ValueError: operands could not be broadcast together with shapes (3,2,4) (3,3,4)
Any help would be appreciated.

Here is the necessary code

{moderator edit - solution code removed}

Print the values you are getting for vert_start and vert_end in all the loops and the error should become apparent pretty quickly. The same mistake exists for the horizontal values.

Please note that we aren’t supposed to share our solution code in a public way, but no harm done as I have edited the post to hide the code.

Thank you Sir, I fixed my error forgot to add stride in certain places. Also Sorry for posting the code by mistake won’t happen again.