Week 2 Logistic Regression with Neural Network Mindset

Hello!! After passing all tests in Exercise 8, I have the following errors while running model. Help pls!!!

logistic_regression_model = model(train_set_x_orig, train_set_y, test_set_x_orig, test_set_y, num_iterations=2000, learning_rate=0.005, print_cost=True)

ValueError Traceback (most recent call last)
in
----> 1 logistic_regression_model = model(train_set_x_orig, train_set_y, test_set_x_orig, test_set_y, num_iterations=2000, learning_rate=0.005, print_cost=True)

in model(X_train, Y_train, X_test, Y_test, num_iterations, learning_rate, print_cost)
26 # parameters, grads, costs = …
27
—> 28 parameters, grads, costs = optimize(w, b, X_train, Y_train, num_iterations, learning_rate, print_cost)
29
30 # Retrieve parameters w and b from dictionary “parameters”

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(np.transpose(w) , X) + b)
32
33 cost = (-1/m) * np.sum(Y * np.log(A) + (1 - Y) * np.log(1 - A))

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

ValueError: shapes (1,209) and (209,64,64,3) not aligned: 209 (dim 1) != 64 (dim 2)

Welcome @condgabriela! You have “thrown” a ValueError and it is telling you that your data input (the X_train argument to the model() function) has not been “flattened”. Review Exercise 2 and make sure that your train_set_x has the proper dimensions.

1 Like