Course 1 week 2 assignment

is model_test( ) function defined outside of the notebook and then is imported?
I’m getting error ;


TypeError 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"

ipython-input-80-ffce8da976df> in model(X_train, Y_train, X_test, Y_test, num_iterations, learning_rate, print_cost)
21 # initialize parameters with zeros (≈ 1 line of code)
22 # initialize parameters with zeros (≈ 1 line of code)
—> 23 w, b = initialize_with_zeros(X_train.shape[0])
24
25 # Gradient descent (≈ 1 line of code)

in initialize_with_zeros(dim)
17 # b = …
18 # YOUR CODE STARTS HERE
—> 19 w=np.zeros(dim,1)
20 b=0
21

TypeError: data type not understood;;;;

i am not understanding why I’m getting error for function initialise_with_zero; there I’m initiation w as np.zeros;

please help

Hey @gug Please make sure you are initialising them as vectors.

hey man thanks for your reply,
im getting error for initialising w as np.zeros(), isnt this a vectorised form?

Can you share the output for your initialise with zeros function ? thanks.

Check how we initialize a matrix with np.zeros ().

1 Like