Conv_forward C4 W1 A1 operands issue

I got this error

"

<ipython-input-51-263d67a7c3f0> in conv_forward(A_prev, W, b, hparameters)
     93                     weights = W[0:1,:,3:5]
     94                     biases = b[0:1,:,3:5]
---> 95                     Z[i, h, w, c] = weights * a_slice_prev + biases
     96 
     97     # YOUR CODE ENDS HERE

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

"

You have to call the conv_single_step function to calculate Z[i, h, w, c]. For more guidance, check this post.

I called the function and followed what the post said, but I still get the error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-99-7e580406a9e8> in <module>
      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]

<ipython-input-96-f7d32c3ce1d7> in conv_forward(A_prev, W, b, hparameters)
     93                     weights = W[:,:,:,c]
     94                     biases = b[0,0,0,c]
---> 95                     Z[i, h, w, c] = conv_single_step(a_slice_prev, weights, biases)
     96 
     97     # YOUR CODE ENDS HERE

<ipython-input-92-87236c9f9391> in conv_single_step(a_slice_prev, W, b)
     23     # Z = None
     24     # YOUR CODE STARTS HERE
---> 25     s = a_slice_prev * W
     26     Z = np.sum(s)
     27     Z = Z + float(b)

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

Maybe you are making mistakes in vert and horiz start and end things or a_slice_prev . Please read that post again and compare your code with it. If still facing issue, let us know…

Thanks, I was able to fix it. It was that I inversed int() and np.floor().