may i ask why TypeError: data type not understood from my run?
the function has been defined …
[Moderator edit: code removed]
may i ask why TypeError: data type not understood from my run?
the function has been defined …
[Moderator edit: code removed]
Hi @Lucy_Hui,
{mentor edit to remove the code}
The dimensions you pass to np.zeros() should be a tuple.
That is not the correct way to invoke the function np.zeros. You can find the documentation by googling “numpy zeros”.
The meaning of that message is that the “zeros” function is telling you that it does not like the arguments that you passed to it.
Hello!
I have defined w = np.zeros((3,1)) (although I don’t understand the reason for the two parentheses)) and b = 0.0 and got a “First test passed!”, but with still “AssertionError: Wrong shape for w. (3, 1) != (4, 1)”.
Did I pass? Or should I correct this difference in the expected shape?
Thanks in advance!
There are two important points there:
np.zeros function takes a “tuple” as the argument giving the shape of the desired output. You can learn more by googling “numpy zeros” and reading the documentation.So how can you fix the “hard-coding” problem? You are passed the requested dimension as an argument, right?
Got it!
I replaced the hard-coding by “dim, 1”, and it worked!
But for b (expected to be an “initialized scalar”), there is no argument passed. So I “hardcoded” as 0.0. Is that right?
And thank you for your quick response!
Yes, the contents of both w and b are zeros (in floating point). But in the case of b, we know it is a scalar, so there is no choice you need to make there.