I ran into an error when I tried to run the optimize part of my code. Here is the code I wrote:
num_features = np.shape(X_train[1])
print num_features
w, b = initialize_with_zeros(num_features)
params, grads, costs = optimize(w, b, X_train, Y_train, num_iterations, learning_rate, print_cost=False)
Y_prediction_test = predict(w,b,X_test)
Y_prediction_train = predict(w,b,X_train)
And here is the error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-43-9408a3dffbf6> in <module>
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"
<ipython-input-42-d09e9e35850c> in model(X_train, Y_train, X_test, Y_test, num_iterations, learning_rate, print_cost)
37
38 num_features = np.shape(X_train[0])
---> 39 w, b = initialize_with_zeros(num_features)
40
41 params, grads, costs = optimize(w, b, X_train, Y_train, num_iterations, learning_rate, print_cost=False)
<ipython-input-17-f3716dfa2501> in initialize_with_zeros(dim)
17 # b = ...
18 # YOUR CODE STARTS HERE
---> 19 w = np.zeros((dim,1))
20 b = 0.0
21
TypeError: 'tuple' object cannot be interpreted as an integer
