C4 Week1 A1: conv_forward convolutional NN error. Help needed

I’m struggling with this weeks assignments. I have been blocked on this one for days and didn’t get any help on my previous messages.
Can you give a hint on why conv_forward in Exercise 3 is not working? Last slice has different shape ((2,3,4) instead of (3,3,4) and breaks the code.

→ 109 Z[i,h,w,c] = conv_single_step(a_slice_prev, weights, biases)

in conv_single_step(a_slice_prev, W, b)
23 # Z = None
—> 25 s = np.multiply(a_slice_prev, W)
26 Z = np.sum(s)
27 Z = Z + np.float(b)

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


1 Like

There are two possible causes:

  • In conv_forward(), either your values for a_slice_prev, weights, or biases is incorrect.
  • There is an error in your conv_single_step() function.
1 Like

There may indeed be a calculation error for vert_start or for vert_end in conv_forward().

1 Like

An error that happened to me was that the boundaries (vertical_start, vertical_end, horizontal_start, horizontal_end) weren’t well defined on a_slice_prev. One thing to keep in mind is that vert_start , vert_end , horiz_start , horiz_end , remember that these are indices of the previous layer, the slide obtained from those boundaries will be applied to the input layer (the previous layer) in order to get a value for the output layer in the cell Z[i, h, w, c]