C4 W1 backprop 5.1 broadcast error

here is my output

can anyone help on where i am doing wrong?

---> 12 dA, dW, db = conv_backward(Z, cache_conv)
     14 print("dA_mean =", np.mean(dA))

<ipython-input-83-0b977ebdbfaa> in conv_backward(dZ, cache)
    106 #                     Update gradients for the window and the filter's parameters using the code formulas given above
    107                     da_prev_pad[vert_start:vert_end, horiz_start:horiz_end, :] += W[:,:,:,c] * dZ[i, h, w, c]
--> 108                     dW[:,:,:,c] += a_slice * dZ[i, h, w, c]
    109                     db[:,:,:,c] += dZ[i, h, w, c]

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

This is conv_backward, it means you’ve passed the conv_forward, right? Revisit that function to get some tips. Let me know if you need our help.


yes i passed the conv_forward, but i wanted to implement the conv_backword also,

I checked this

i was following the same,but still it is not working , idk why

Please send me your code of conv_backward function in a private message. Click my name and message.

looks like your a_slice is only 2D, while everything else on that line is 3D. Is that what you wanted? Maybe revisit the slicing parameters.