# Week 2 Exercise 5 unable to spot error

def propagate(w, b, X, Y):

m = X.shape[1]

A = (np.dot(w.T,X))+b
error here —> cost = np.dot((-1/(m)), (np.sum( np.dot(Y, np.log(A)) + np.dot((1 - Y) , np.log(1-A)) ) ) )

dw = np.dot((1/(X.shape(1))) , (np.dot(X, (A-Y).T)) )
db = np.dot((1/(X.shape(1))), (np.sum(A-Y)))

cost = np.squeeze(np.array(cost))

“db”: db}

``````return grads, cost
``````

ValueError: shapes (1,3) and (1,3) not aligned: 3 (dim 1) != 1 (dim 0)

I could not spot my mistake, can anyone help please? Am I on the right track or is my work completely nonsense?

Hi @Efe_Baydar welcome to Discouse and I hope you are enjoying the course.
You are not completely off track, don’t worry. Have a look at the hints above the instruction. It indicates how you have to calculate A, which should use the sigmoid function. So let’s first fix that, and then check the rest.

1 Like

def propagate(w, b, X, Y):

m = X.shape[1]

A = sigmoid ( np.dot(w.T,X))+b )
cost = np.dot( (- 1/(m) ), ( np.sum( np.dot(Y, np.log(A) ) + np.dot( (1 - Y ) , np.log( 1-A ) ) ) ) )

dw = np.dot((1/(X.shape(1))) , (np.dot(X, (A-Y).T)) )
db = np.dot((1/(X.shape(1))), (np.sum(A-Y)))

cost = np.squeeze(np.array(cost))