Really appreciate your explanations! I initialize w and b, and then call the optimize twice (using (X_train, Y_train), and (X_test, Y_test)). I do this because I then call the predict function to get the predicted y using ‘Y_prediction_test = predict(w, b, X_test)’.

##
I encounter the following error:

ValueError Traceback (most recent call last)

in

1 from public_tests import *

2

----> 3 model_test(model)

~/work/release/W2A2/public_tests.py in model_test(target)

113 y_test = np.array([0, 1, 0])

114

→ 115 d = target(X, Y, x_test, y_test, num_iterations=50, learning_rate=0.01)

116

117 assert type(d[‘costs’]) == list, f"Wrong type for d[‘costs’]. {type(d[‘costs’])} != list"

in model(X_train, Y_train, X_test, Y_test, num_iterations, learning_rate, print_cost)

35 # YOUR CODE STARTS HERE

36 w, b = initialize_with_zeros(dim)

—> 37 params, grads, costs = optimize(w, b, X_test, Y_test, num_iterations, learning_rate, print_cost)

38 w = params[“w”]

39 b = params[“b”]

in optimize(w, b, X, Y, num_iterations, learning_rate, print_cost)

35 # grads, cost = …

36 # YOUR CODE STARTS HERE

—> 37 grads, cost = propagate(w, 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

33 cost= -1*(np.dot(Y, np.log(A.T)) + np.dot((1-Y), np.log(1-A.T)))/m

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

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

Could I get some suggestions on how to troubleshoot it? Thank you