An error in initializing with zeors

Hi,
I’ve been following other threads on similar problems but couldn’t find a solution to mine.

In Week 2 assignment I initialized the parameter b by b=0. .
Using print(type(b)) I can see that it is indeed a float variable, as needed.
But I keep getting one failed test with error message “wrong shape of variable 0”.

I also have an error with running the model, and I wonder if the former problem has anything to do with it. In model, I checked the data types of b after initializing and after retrieving, and they do seem to alternate between float and float64, as I think they should.

Any help would be very much appreciated.

@kalishor ,

Some of us faced the similar problem and its discussed in this message: Course 1 week 2: bias 'b' value type in model vs initialize_with_zeros

Primarily, in model, we need to update the value of b and w in d(return value) as

     "w" : params["w"],  # from ("w": w)
     "b" : params["b"],   # from("b": b)

Or assign
w, b = params["w"], params["b"]

I think, this change is needed to return the learned weights and biases to the model inference.

1 Like

Thank you so much for your reply. I made the changes you suggested in model but it didn’t solve the problem, unfortunately.

My first problem, which might be causing the second, is that initialize_with_zeros keeps failing one test. I can’t figure out why, after all, this part is only two, very short, lines of code.
Reading the discussion you’ve linked to suggests that you did not face any problem with 4.2, am I right?

Solved it. Thank you!
After all, there as no need to change anything in model.
Thanks a lot.

1 Like