# Np.zeros assertion error

Already working on Programming Assignment: Logistic Regression with a Neural Network Mindset have problem with correct dtype. Setting b.astype(float) doesn’t work too.

b=np.zeros(2,dtype=float)
print(b)
print(str(b.dtype))
assert type(b) == float

[0. 0.]
float64

AssertionError Traceback (most recent call last)
in
2 print(b)
3 print(str(b.dtype))
----> 4 assert type(b) == float

If you use `np.zeros`, then b ends up being a numpy array, right? You can see what is going on by adding a print statement like:

`print(f"type(b) = {type(b)}")`

Try that and see what happens. You want it to be a scalar value. Also note that you have to be careful because 0 is not a float in python: it’s an integer.

But if that means, an array made by np.zeros is seen as ndarray of int then how to change b to type of float when declaration with arg: dtype=float does not work? And b.astype(float) is seen as float64, not float… The use of compatible float_ does not work too…
In this case the statement assert type(b) == float has no sense!
If I edit the exercise in my offline notebook I get as follows:
AssertionError:
w = [0. 0.]
b = [0. 0.]
<class ‘numpy.ndarray’>
Therefore I see it as an error made in the exercise code.
But never mind, I simply misunderstood what to do with b ;D Now I must to think how to set the right shape to w.
Yes, it sounds like you were fundamentally missing the point that b is a scalar. Glad that is clear now. For the w case, note that your array has only 1 dimension. It needs to be a two dimensional object. The argument to `np.zeros` needs to be a “tuple”, not a list of arguments.