W2_A2_model_test(target) triggers error

Hi,

Thanks for reading this message.
All the function implemented correctly (passed).

I get errors on the last model function call which basically just calls the functions built before.

Appreciate if someone can assist.


TypeError Traceback (most recent call last)
in
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"

in model(X_train, Y_train, X_test, Y_test, num_iterations, learning_rate, print_cost)
20 # initialize parameters with zeros
21 # w, b = …
—> 22 w, b = initialize_with_zeros(X_train.shape([0]))
23
24 #(≈ 1 line of code)

TypeError: ‘tuple’ object is not callable


Thanks
Nazih

I think your problem here. X_train.shape return a tuple, so you want to take the first element is X_train.shape[0].

Thank you for your prompt reply. Appreciated.
It seems I added extra parathesis.

Removed the extra parenthesis to make it read:
w, b = initialize_with_zeros(X_train.shape[0])

That solved my problem.
Thank you!

1 Like