Trouble Initializing Model

In the second programming assignment for week one where we initialize the variables for w and b (section 4.2), I’m not able to get it to run with any version of np.zeros(dim) or np.zeros(dim,1) etc. I set b = 0 directly.

I get the following:

TypeError Traceback (most recent call last)
in
1 dim = 2
----> 2 w, b = initialize_with_zeros(dim)
3
4 assert type(b) == float
5 print ("w = " + str(w))

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

TypeError: data type not understood

Help would be appreciated, I can’t move on from here if the variables won’t initialize correctly and I don’t know what I’m doing wrong.

I’m pretty sure you mean Week 2?

When you opened the notebook, did you run all of the cells starting from the top?

That’s how the workspace is created and all of the assets are imported.

You have to do this every time you open the notebook.

When you exit the lesson, your changes to the notebook are saved, but the state of the environment is not.

Note that the exception does not happen on the line that assigns the value to b. The syntax you are using to invoke np.zeros is not correct. Here’s the docpage for that function. Note that the first argument is a “tuple” that gives the dimensions you want for the created object.

1 Like

Also note that once you fix that problem, you will also have a problem with the way you have initialized b. It needs to be a floating point value. In python 0 and 0. are not the same thing: the former is an integer.

1 Like