Assertionerror Week2 Exercise 8

Hi,I have the following assertionerror on exercise 8.

. AssertionError Traceback (most recent call last)
1 from public_tests import *
----> 3 model_test(model)
~/work/release/W2A2/ in model_test(target)
113 y_test = np.array([0, 1, 0])
→ 115 d = target(X, Y, x_test, y_test, num_iterations=50, learning_rate=0.01)
117 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)
49 Y_prediction_train = predict(w, b, X_train)
—> 51 assert type(b) == float
52 print ("Type of b = ", type(b))
53 print ("w = " + str(w))

It seems b is not float. However, i tested and find out it is float, but a different type:

Type of b = <class ‘numpy.float64’>

I’ve read about it, but couldn’t understand how to solve this. I suppose they’re not really different, but I can’t go on with the exercise (actually, I commented the assertion line, but i want to be sure this is ok).

It is not a good idea to comment out the assertion in general, although it probably wouldn’t really make that much difference. In fact, I thought that test cell could not be edited.

Try just assigning b like this, instead of explicitly assigning to the type of “float64”:

b = 0.0

That is a simple way to pass the test. It just makes it the default floating point type in python.

1 Like