Course -1,Week 2, Ex-8, Value error with reshaping

ValueError Traceback (most recent call last)
----> 1 model_test(model)

~/work/release/W2A2/ in model_test(target)
109 y_test = np.array([1, 0, 1])
→ 111 d = target(X, Y, x_test, y_test, num_iterations=50, learning_rate=1e-4)
113 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)
40 b = params[“b”]
—> 42 Y_prediction_test = predict(w, b, test_set_x)
43 Y_prediction_train = predict(w,b,train_set_x)

in predict(w, b, X)
16 m = X.shape[1]
17 Y_prediction = np.zeros((1, m))
—> 18 w = w.reshape(X.shape[0], 1)
20 # Compute vector “A” predicting the probabilities of a cat being present in the picture

ValueError: cannot reshape array of size 12 into shape (12288,1)

Above is the error I am getting, Can anyone help with this.

1 Like

Did your test for optimize() pass?

Yes, I got all test passed for the optimize() test.

Where are you getting test_set_x? The problem is most likely caused with whatever you’re doing to get test_set_x from X_test. I believe it’s using test_set_x from the preceding code blocks and hence it contains irrelevant data.

Thank you for your response I didn’t find exact cause for the error but after closing it and again I tried the programming task today . I went with the same but it got worked.