Week2 initializing parameter

while initializing parameters I get error -
w,b = initialize_with_zeroes(dim)
data type not understood.

Please share full error.

i initialised parameter w with zeroes using numpy.zeros, setting dimension dim,1 ;
and d to 0.
I got above error… pls resolve

Devansh,

Saif is asking you if you can take a screenshot of the error you have encountered after you have run the cell. So further guidance can be given.

Regards
DP

oh yes!my bad sir!
here is the attached screenshot of the error

devansh

do you see an assertion statement in the grader cell?

what w parameter is missing in your code line in relation to the assertion statement for w?

1 Like

I suggest reading this np.zeros documentation. You should check example 3 given in that link and below:

>>> np.zeros((2, 1))
array([[ 0.],
       [ 0.]])

sir i tried this its giving assertion error

Please check the parentheses a bit more carefully. You can’t be sloppy about that kind of thing in programming: every character matters and you have to understand the syntax that is required. Did you follow Saif’s advice and actually read the documentation for np.zeros?

1 Like

sir i did read it!

sir this is the error i am facing

Great! So you fixed the np.zeros call and now you’re on to the next problem. The assertion is telling you that b needs to be a scalar floating point value. But you set it to 0, right? That is an integer in python. So how would you make that a floating point value instead? Hint: in python 2 and 2. are not the same thing. :nerd_face:

Or if you didn’t have this hint, then the way to debug this would be to print the type of your b value:

print(type(b))

If you do that, what do you see? Why is it not “float”?

Debugging is part of the job here. You wrote the code, but it doesn’t work. Now you need to figure out why. The assertion is telling you that the type is not “float”, so your first question is “Ok, then what type is it?” Then the next question is “How do I fix that to make it be a float?”

do i need to write float(b) in assertion cell sir?!

You can’t change the assertion cell. You need to change your code. Did you read what I said? There’s a hint there.

Try your solution and see what happens. Does that fix the problem?

Note that as is frequently the case in programming, there is more than one way to fix this problem. Any of them will do.

So I changed my code to 0.0 the code ran successfully.
thankyou @paulinpaloalto @saifkhanengr @Deepti_Prasad for all your help.