C4 W1 conv_forward

Hi

I am stuck on the conv_forward() function of the first programming assignment. I looked into previous topics with this issue, but I can’t seem to find a solution.

Can someone help me, please?

This is the error I get:

ValueError                                Traceback (most recent call last)
<ipython-input-28-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-27-cdd970238433> in conv_forward(A_prev, W, b, hparameters)
    106                 weights = W[:,:,:,c]
    107                 biases = b[:,:,:,c]
--> 108                 Z[i, h, w, c] = conv_single_step(a_slice_prev, weights, biases)
    109 
    110     # YOUR CODE ENDS HERE

<ipython-input-21-6fbb7606732a> in conv_single_step(a_slice_prev, W, b)
     24     # YOUR CODE STARTS HERE
     25     # Element-wise product between a_slice_prev and W
---> 26     s = np.multiply(a_slice_prev, W)
     27     # Sum over all entries of the volume s
     28     Z = np.sum(s, axis = None)

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

Thank you!

Please fix the mistake when calculating horiz_end.

Don’t forget to remove code from the post as posting code in public could get your account suspended.
It’s okay to leave stacktraces in public though.
Here’s the community user guide to get started.

Hi,
Thank you for your quick answer. However, fixing the mistake doesn’t fix the error I get.

Please click my name and message your notebook as an attachment.

Please fix the following:

  1. Calculation of n_H and n_W. You’ve left out one term.
  2. The indentation of loops is incorrect. There are 4 nested loops. Look at the videos and markdown again if required.
  3. Range of w and h.

Thank you so much! It worked.