Week 1 Exercise 5 conv backward

hello dear community, i’m stuck in this optional exercise i just made a copy paste and an error message in brodcast shapes still appearing can someone help me please ?
(A_prev,W,b,hparameters)= (cache[0],cache[1],cache[2],cache[3])
(m,n_H_prev,n_W_prev,n_C_prev)=A_prev.shape
(f,f,n_C_prev,n_C_prev)=W.shape
stride=hparameters[“stride”]
pad=hparameters[“pad”]
(m,n_H,n_W,n_C)=dZ.shape
dA_prev=np.zeros([m, n_H_prev, n_W_prev, n_C_prev])
dW=np.zeros([f, f, n_C_prev, n_C])
db=np.zeros([1, 1, 1, n_C])
A_prev_pad = zero_pad(A_prev, pad)
dA_prev_pad = zero_pad(dA_prev, pad)
for i in range (m):
a_prev_pad=A_prev_pad[i]
da_prev_pad=dA_prev_pad[i]
for h in range (n_H):
for w in range (n_W):
for c in range (n_C):
vert_start=hstride
vert_end=vert_start+f
horiz_start=w
stride
horiz_end=horiz_start+f
a_slice=a_prev_pad[vert_start:vert_end,horiz_start:horiz_end,c]
da_prev_pad[vert_start:vert_end,horiz_start:horiz_end,:]+= W[:,:,:,c] * dZ[i, h, w, c]
dW[:,:,:,c]+= a_slice * dZ[i, h, w, c]
db[:,:,:,c]+= dZ[i, h, w, c]



in conv_backward(dZ, cache)
89 horiz_end=horiz_start+f
90 a_slice=a_prev_pad[vert_start:vert_end,horiz_start:horiz_end,c]
—> 91 da_prev_pad[vert_start:vert_end,horiz_start:horiz_end,:]+= W[:,:,:,c] * dZ[i, h, w, c]
92 dW[:,:,:,c]+= a_slice * dZ[i, h, w, c]
93 db[:,:,:,c]+= dZ[i, h, w, c]

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

You are setting n_C_prev incorrectly. You set it to be the last dimension of W. That is n_C, right? I know you set it to other things earlier, but that is the last assignment to n_C_prev, so it over-rides the others, I believe.

thanks a lot !!
it was an error of typing :blush: