regarding Exercise 2 for this function : conv_single_step()
I converted the last value Z to float
the value is correct but the datatype is worng which cause the test to fail.
what do I miss?
regarding Exercise 2 for this function : conv_single_step()
I converted the last value Z to float
the value is correct but the datatype is worng which cause the test to fail.
what do I miss?
Yes, this is all a bit tricky and the instructions aren’t that clear. The problem there is that float
is the basic python floating point type, but they are asking for a numpy np.float64
. There are a couple of problems with the way you coded it:
np.add
ends up being a numpy array, not a scalar.Instead of the two lines you have, it turns out either of these combinations works:
Z = Z + float(b)
or
Z = Z + np.float64(b)
it works well with your proposals but I have two questions remaining.
1- would it be a code issue if we have different datatype like ?
2- why did we define ‘b’ as np.random.randn(1, 1, 1) ? would be easuer to make it one float instead of np array of one entry ?
The problem is that the tests and the grader check the output type, so it needs to agree. Or to put it another way: yes, the type matters.
For question 2), the point is that the bias terms are 4D tensors. Then we slice them down to 3D tensors as we iterate over the output channels. That’s what they are, so we have to deal with them in the form that they are, right?
The filters at each level are 4D tensors with shape f x f x nc_{in} x nc_{out} and we “slice” them by the output channel in the conv_forward
loop.
The bias values at each level are 4D tensors with shape 1 x 1 x 1 x nc_{out} and we “slice” them by the output channel in the conv_forward
loop.