Hi I’m new to coding so I’m struggling with some basics. In the week 2 HW section 4.2 initializing parameters, I tried the following and get errors:
w = np.zeros((dim,1))
b = 0
Why this is wrong?
Hi I’m new to coding so I’m struggling with some basics. In the week 2 HW section 4.2 initializing parameters, I tried the following and get errors:
w = np.zeros((dim,1))
b = 0
Why this is wrong?
Hi @chenf12, it is not allowed to attach results in the notebooks in the forum, can I kindly ask you to remove the screen with the solution and, as well, the subsequent solution code? About your problem: the test code states an erroen on assert type(b) == float
. This line checks weaker b is of type float
which is not true in your case. So basically b has not the expected type. Hint: the type depends, in this case, on how b has been initialized since the python interpreter will infer the type from how b in initialized.
Thanks for you response. I’m new to this forum and my apologize for uploading the image of the code. I edited the original post and I think I removed the screenshot. If there is still an issue please let me know.
I guess my follow up question is how to initialize a float variable b? It is supposed to be a scalar variable, but I tried b = np.zeros((dim,), dtype = float), and b= float, and also b = np.zeros(dim), but none of them work. My apologize for asking stupid questions but as a new learner of coding, I’m not sure what’s the best way to follow the instruction.
Dear @chenf12 the value of b needs to be a scalar type (not a numpy array) of class float and zero valued. Your first initialization was setting as an integer. Some example of initialization here. Hopes gives you a hint.
This is very helpful! Thanks I figured it out.