Error in week 2 code

Can someone help me figure out that what is the error here?

AssertionError Traceback (most recent call last)
in
7 assert type(grads[“dw”]) == np.ndarray
8 assert grads[“dw”].shape == (2, 1)
----> 9 assert type(grads[“db”]) == np.float64
10
11

AssertionError:

grads[‘db’] should be a float and not something else like an array or array containing a float.

1 Like

Did you propagate grads and cost?

1 Like

Hi, @Srishti_Kumari. The test cell is checking that db is of the proper data type. Python has many types of objects (e.g. integers, floats, strings, lists, dicts, etc). Here, we want to make sure that db is of type float, or more specifically, np.float64. This simply means that it’s a floating point number (i.e. it has a decimal point) and not an integer, or any other type for that matter. Assuming that your expression for db is correct, you can fix this by simply wrapping it in the np.float64() function. That is db = np.float64(your expression).

1 Like

In order to debug this, the first step is to print the type of your db value:

print(f"type(db) = {type(db)}")

What type is it actually? If the answer is that your value is of type np.array, then make sure that you did not specify the keepdims = True argument on the call to np.sum to compute db.

1 Like

Thank You all,
I corrected my mistake as I assigned a vector to a float type I was getting this error.