Course 1 Week 2 Programming assignment

Hi for the assignment, Logistic_Regression_with_a_Neural_Network_mindset

i am getting an error at exercise 8 -


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)
123 y_test = np.array([[0, 1, 0]])
124
→ 125 d = target(X, Y, x_test, y_test, num_iterations=50, learning_rate=0.01)
126
127 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)
24 #(≈ 1 line of code)
25 # Gradient descent
—> 26 params, grads, costs = optimize(w, b, X, Y, num_iterations, learning_rate, print_cost)
27
28 # Retrieve parameters w and b from dictionary “params”

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
40 # YOUR CODE ENDS HERE

in propagate(w, b, X, Y)
27 #(≈ 2 lines of code)
28 # compute activation
—> 29 A = sigmoid(np.dot(w.T,X) + b)
30 # compute cost by using np.dot to perform multiplication.
31 # And don’t use loops for the sum.

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

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

The problem is that you are referencing the global variables X and Y when you call optimize from model. Where are those variables defined? They have nothing to do with the actual values used in the model function, right?

1 Like

Yes you’re right! Have just fixed it :slight_smile:

1 Like