Course 1 week 2 assignment ex8

to reference X_train using initialize_with_zeros, I keep getting the error attached:

I also get this error in ex2

@DaliaMa check the initialize_with_zeros funtion in your code and see if there is any typo in the name.

First check for any typos in your function names.
Secondly, initialize b as a float, not as an int

Try it.

Do not go to another exercise if your first exercise is not running

I checked for any typos in the name but it was correct, now it’s generating an error with the np.zeros() function.

I added a line to initialize b as a float, I wrote first that b is equal to zero and then wrote the line using the assert function that showed in the error to initialize b as a float, then it gave me a different error with the np.zeros(), I used it to initialize w, I’m not sure if this was the right thing.
assignmnet1ex4

Run the cell from beginning once. Here it shows numpy is not defined as error

@DaliaMa as suggested by @happyman you need to execute the cell where numpy is being imported. Also, in your code you are not defining b as a float as @andreitulburet pointed out.

I did it now yea it recognize it thank you so much.

how can I define b as a float? in my code I wrote that b is equal to zero, then I wrote assert type b exactly like line 4 is written in the error to define it but it gives me an assertion error, how can I type it correctly?
I also tried to type it: assert( , ) but it also gives me assertion error.
ex4

HI @DaliaMa, the assert keyword won’t help

The assert keyword lets you test if a condition in your code returns True, if not, the program will raise an AssertionError.

The easiest way to define a number as a float is to write it as a float:

>>> a = 1.5
>>> type(a)
<class 'float'>

If you write 0 as an int (i.e. no decimals) then it will be interpreted as an int.

Thank you so much I get it now and I corrected the code and it worked, now the final exercise is giving me this error

I don’t know if there are other errors but you are not applying the right reshape. Maybe you could check this post to improve your understanding of the reshape function.

I got a syntax error from
type(a)
<class ‘float’>

Also got syntax error
type(a) <class ‘float’>

Thanks, Nancy

Hi, I’m not sure to what you are refering to now. My example above was just to demonstrate how to define a number as a float so when you initialize b you do it as a float. In your code you had:

b = 0

The type of b in that case would be int and you will have an error with the tester.

I understand. But when I used your code to set b to float I got a syntax error

Could you please write out code again

I’ve spent time on Python.org can’t figure out
Can we just Invalides b=0.0
Thank you

Hi, if you write b = 0. or b = 0.0 shouldn’t raise any error. What kind of error are you getting?
My example was just to illustrate how to define a float, it was nothing specific regarding the assignment.