Dear Albertovilla,

Thank you for your response. The function ‘propagate’ (where ‘A’ is defined) was written correctly before implementing the function ‘optimize’. When I run the following code that is given after defining ‘propagate’ function, the test is passed as shown below:

*w = np.array([[1.], [2.]])*

*b = 2.*

*X =np.array([[1., 2., -1.], [3., 4., -3.2]])*

*Y = np.array([[1, 0, 1]])*

*grads, cost = propagate(w, b, X, Y)*

*assert type(grads[“dw”]) == np.ndarray*

*assert grads[“dw”].shape == (2, 1)*

*assert type(grads[“db”]) == np.float64*

*print ("dw = " + str(grads[“dw”]))*

*print ("db = " + str(grads[“db”]))*

*print ("cost = " + str(cost))*

*propagate_test(propagate)*

*dw = [[0.99845601]*

- [2.39507239]]*

*db = 0.001455578136784208*

*cost = 5.801545319394553*

*All tests passed!*

However, After defining the function ‘optimise’, when test function by running the below lines

*params, grads, costs = optimize(w, b, X, Y, num_iterations=100, learning_rate=0.009, print_cost=False)*

*print ("w = " + str(params[“w”]))*

*print ("b = " + str(params[“b”]))*

*print ("dw = " + str(grads[“dw”]))*

*print ("db = " + str(grads[“db”]))*

*print("Costs = " + str(costs))*

*optimize_test(optimize)*

I get this error which is weird b/c it ‘np.dot’ worked before and now its giving the error:

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)

36 # YOUR CODE STARTS HERE

37

—> 38 grads, cost = propagate(w, b, X, Y)

39 # YOUR CODE ENDS HERE

40

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.sum(Y*np.log(A)+(1-Y)*np.log(1-A))

33 # YOUR CODE ENDS HERE

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

Please do suggest where am I doing it wrong. Thank you.