Hi folks,

I’ve been up all night and still can’t fix the bug in exercise 3 (conv_forward). I quite doubt that my code is buggy. I have calculated all cases, vert_start includes stride, the range of n_H, even the weights W[:,:,:,c]. But the test case shows me that:

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

and I think maybe there is a problem with my conv_single_step function (although I passed this)

—> 25 s = np.multiply(a_slice_prev,W,dtype=float)

But I have no idea what is it. Please someone or help me clear, I would appreciate it if someone can help me get through this.

Thank you.

I think the problem is in *conv_forward*, not in *conv_single_step*. My first suggestion is to check carefully to make sure that your code for handling the horizontal dimension is exactly the same as your code for the vertical dimension. Remember that h is for height (vertical) and w is for width (horizontal). You error is on the w dimension of *a_prev_pad*, so that’s the place to look for the error.

Hi Paul,

Here is my code for handling the horizontal and vertical, I still don’t know where is the error come from, I modified it a little bit to avoid revealing the solution. Can you take a look at, please? Thank you so much.

for h in range(height of out put):

for w in range(width of out put):

for c in range(none):

vert_start = h * stride

vert_end = vert_start + None

```
horiz_start = w * stride
horiz_end = horiz_start + None
```

1 Like

Why are you adding None in both cases? It should be the filter size, right?

Yes, I changed it to not reveal the results

Ah, sorry, that makes sense. I don’t see anything wrong with your logic as you’ve described it so far.

Hi Paul,

I figured it out, turns out I forgot to subtract filter size when calculating n_H and n_W.

Thank you once again

1 Like

It’s great to hear that you found the solution! Thanks for confirming.