On conv_single_step assignment, when adding b to Z, we were supposed to cast b value to float. When I used b.astype(float), it gave me an error message. When I simply used float(b), it worked just fine. Could someone explain the difference between the two functions? Thank you.
The code you should use is np.float(b).
It is mathematically equivalent to float(), but more consistent since Z is also an np data type.
I don’t really know why astype() caused a problem. What was the error message?
I also received an error when I used b.astype(float). However, float(b) and np.float(b) worked fine.
I made the same error: b.astype(float) doesn’t convert b to float but converts values of b to floats in the matrix b.
Reviving this in case anyone can shed light on this. I got the workaround, but I am too struggling to understand why casting it as .astype to a float doesn’t work.
I’ve tried troubleshooting playing around with matrices and it seems like it should work. Is this a bug in the lab or is there something I’m missing about data types and numpy?
The error I got failed on the assert “AssertionError: You must cast the output to float.”
However, if I print (Z.dtype), I get float32…