W2_A2_Ex-8: Value_error

I am having an issue with this exercise and the following error is attached. I am not sure exactly where I am going wrong since the shape of w is correct i.e., 4,1.

Moderator Edit: Solution Code Removed

As an additional point, all tests have passed prior so I do not see the issue why it would not work unless:

params, grads, costs = optimize(w, b, X_train, Y_test, num_iterations, learning_rate, print_cost=False) in lieu of leaving X and Y as is

In the context of the model function, the variables X and Y are not defined. Instead, you should pass in X_train and Y_train as they are the training data. The error can be caused by using these undefined variables inside the function.

1 Like

What is X and Y for a model function? You are using X and Y that are defined outside of the function, Global variable. You should use local variable that is passed to a function as an argument or defined inside of it.

PS: Sharing your code is not allowed. For now, I am deleting it but better be careful in the future.

2 Likes