I'm getting an error in shapes when computing the cost

I’m working on W2_A2_E5
and I wrote this to compute the cost :
cost = (-1/m) * (np.dot(Y,np.log(A)) + np.dot((1-Y),np.log(1-A)))

but I’m getting this error:
shapes (1,3) and (1,3) not aligned: 3 (dim 1) != 1 (dim 0)

can someone help me please I couldn’t understand the error

Check the shapes of the matrices, Y and Np.log(A) and the second pair, it seems the matrix multiplication cant be achieved because of that.

the shapes of both A and Y are (1,3)

You need to transpose one term.

1 Like