Exercise 4 - Initialize with Zeros

Hi there,

I’m stuck on exercise 4, I’m trying to initialize w and b using np.zeros() but I keep getting an assertion error. Any suggestions would be appreciated.

Thanks!

Exercise 4 - Initialize with Zeros

Hi there,

I’m stuck on exercise 4, I’m trying to initialize w and b using np.zeros() but I keep getting an assertion error. Any suggestions would be appreciated.

Thanks!

Hi @Bhavini

Welcome to the community!

I think that this error because that function np.zeros() get only one parameter to make a list of zeros with shape (n,1) so you want to create an matrix or array of zeros you want to make a tuple of the shape of matrix you want to initialize like if you want to create an array of 2 rows and 3 columns with initial values of zeros so you will use nop.zeros((2,3))

Cheers,

Abdelrahman

What does the assertion say? That should be the clue that drives your investigation. The first rule of debugging is “believe the error message”. If you don’t understand what it is saying, then that is the first thing you need to fix.

The assertion that most commonly fails for people on this function is the one that asserts that b has type “float”. Note that in python 0 and 0. are not the same thing. The former is an integer. Or if you use `np.zeros`

to initialize b, then you end up with the type being “numpy array”. But b is a scalar float, right?

Thanks everyone, I was able to pass the test cases.