[Week1] Project1 conv_backward

[solved]

Code below:

And I got error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-36-3575597a0654> in <module>
     10 
     11 # Test conv_backward
---> 12 dA, dW, db = conv_backward(Z, cache_conv)
     13 
     14 print("dA_mean =", np.mean(dA))

<ipython-input-35-479170ef8808> in conv_backward(dZ, cache)
     67                     # Update gradients for the window and the filter's parameters using the code formulas given above
     68                     temp =  W[:,:,:,c] * np.squeeze(dZ[i, h, w, c])
---> 69                     da_prev_pad[vert_start:vert_end, horiz_start:horiz_end, :] += temp
     70                     dW[:,:,:,c] += a_slice * dZ[i, h, w, c]
     71                     db[:,:,:,c] += dZ[i, h, w, c]

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

I just copied the code provided by the instruction, can anyone tell me where the problem is?

Sorry guys, my fault.

a_prev_pad and da_prev_pad should be sliced from A_prev_pad and dA_prev_pad respectively

Please do not post your code on the forum. That’s not allowed by the course Honor Code.

Hi, I’ve edited and corrected it.