Hi,
All of my functions passed the tests, but I am getting an error message in Exercise 8 when I am trying to put together the model.
# (≈ 1 line of code)
# initialize parameters with zeros
# w, b = ...
#(≈ 1 line of code)
# Gradient descent
# parameters, grads, costs = ...
# Retrieve parameters w and b from dictionary "parameters"
# w = ...
# b = ...
# Predict test/train set examples (≈ 2 lines of code)
# Y_prediction_test = ...
# Y_prediction_train = ...
I believe I correctly implemented the above instructions but I am getting the following error when I run the model_test(model)
error:
ValueError Traceback (most recent call last)
in
----> 1 model_test(model)
~/work/release/W2A2/public_tests.py in model_test(target)
109 y_test = np.array([1, 0, 1])
110
→ 111 d = target(X, Y, x_test, y_test, num_iterations=50, learning_rate=1e-4)
112
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)
43 b = params[“b”]
44
—> 45 Y_prediction_test = predict(w, b, X_test)
46 Y_prediction_train = predict(w, b, X_train)
47
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)
19
20 # Compute vector “A” predicting the probabilities of a cat being present in the picture
ValueError: cannot reshape array of size 2 into shape (4,1)
I spent more than an hour trying to fix this error. I am at a loss.