C1 W2 Logistic Regression with a Neural Network mindset: Exercise 6-optimize

I get below error message when run excercise6 optimize. I check all my answers above, all of them are correct.
I’m not sure why I’m getting the shape error. :frowning:


ValueError Traceback (most recent call last)
in
----> 1 params, grads, costs = optimize(w, b, X, Y, num_iterations=100, learning_rate=0.009, print_cost=False)
2
3 print ("w = " + str(params[“w”]))
4 print ("b = " + str(params[“b”]))
5 print ("dw = " + str(grads[“dw”]))

in optimize(w, b, X, Y, num_iterations, learning_rate, print_cost)
35 # grads, cost = …
36 # YOUR CODE STARTS HERE
—> 37 grads, cost = propagate(x,b,X,Y)
38
39 # YOUR CODE ENDS HERE

in propagate(w, b, X, Y)
29 # cost = …
30 # YOUR CODE STARTS HERE
—> 31 A = sigmoid(np.dot(w.T,X)+b)
32 cost = (1/m)*(-np.dot(Y,np.log(A).T)-np.dot((1-Y),np.log(1-A).T))
33 # YOUR CODE ENDS HERE

<array_function internals> in dot(*args, **kwargs)

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

You are not passing the correct arguments to propagate when you call it from optimize. Your propagate code looks correct, but it can still throw an error if you pass it mismatching arguments. The actual bug is higher up the call stack.

Thanks for your reply! I found the bug :slight_smile: