I’m facing problem in assignment where i intialize variables w and b to zeros but after running the code it shows assertion error == float . What is the reason i’m using np.zeros(x)

Hey @Asad_Ullah_Wallana,

It looks like you have initialized b as `0`

. As mentioned in the function’s description, it’s supposed to be of type float. Now, look into what you can do to transform it into a float-type value, or better, initialize it as a float-type value. Let me know if this helps.

Cheers,

Elemento

The other thing to check is that you used `np.zeros`

only for the initialization of w. Note that b is a scalar. If you initialize b with `np.zeros,`

then the type is `np.array`

, not `float`

, so the assertion will still fail.

i have defined as np.zeros(x, dtype=float) and still same error of assertion

i think there is some problem with the sheet now the error has vanished and the new problem is data type not understood for w also it is showing me syntax error at dw and when i removed the dw and db from code it showed the same syntax error at cost

Also i want to ask another question that when i initialize b to zeros (x,1) then an error "data type not understood

The syntax error you can’t find is probably caused by a missing close paren on the *previous* line.

It looks like you didn’t understand what I said in my previous reply. Here is the same point expressed in a different way:

w is a vector, so you need to initialize it using `np.zeros`

. The point is that the output of `np.zeros`

is a numpy array containing floating point zeros of the requested dimensions.

b is a scalar value, so you cannot use `np.zeros`

in that case. You just assign it a value with a simple python assignment statement. But there you need to keep in mind the point that Elemento made in his earlier reply: in python 0 and 0. are not the same thing: the first one is an integer (which will fail that assertion again) but the second one is a floating point value. See the difference?

You also need to be careful about the syntax of the `np.zeros`

call. Here is the documentation, which I found by googling “numpy zeros”. Notice that it takes a “tuple” as the argument to give the shape that you want.

But as mentioned above, it is a mistake to use it in the case of initializing the bias value b.

thanks a lot, I understood your point and the problem is solved as well .