New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
float16 normalization problem with numpy >= 1.21 #21559
Comments
It's bad that we did not have a test to catch this regression earlier. I confirm I can reproduce the exact same results on macos/arm64, so this is not platform specific. It seems that with numpy 1.21.2 |
On numpy 1.21.2: >>> np.einsum("ij,ij->i", test, test)
array([0.], dtype=float16) while on previous numpy: >>> np.einsum("ij,ij->i", test, test)
array([175.6], dtype=float16) and on both numpy versions: >>> (test ** 2).sum()
175.6 so there is a regression in |
I found a minimal reproducer, I will report it upstream. |
This is seems to have already been reported as: numpy/numpy#20305. |
Thanks @ogrisel ! Should I close this issue out because it's numpy? or keep it open ? |
We can keep it open just to track the regression. |
Looks like the bug was fixed in numpy and will be backed ported in numpy 1.21.5 XREF: numpy/numpy#20462 |
Closing because this issue was fixed in NumPy. |
Describe the bug
Hi!
I think sklearn.preprocessing.normalize doesn't work properly on float16 for the latest versions of numpy. I am not sure if this is a bug with numpy or sklearn, but figured folks might want to know. I think for dense matrices,
np.einsum
is used to compute norms, so the instability might be there. Regardless...Steps/Code to Reproduce
Expected Results
regardless of numpy version,
np.linalg.norm
should be close to 1 after normalizationActual Results
the norm is 13 for any numpy 1.21.+
Versions
see above --- I'm using the latest sklearn, but if i also use the latest numpy, float16 normalization no longer seems to work.
The text was updated successfully, but these errors were encountered: