You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/12/22 12:22:07 UTC
[GitHub] [incubator-mxnet] vjache edited a comment on issue #17143: Wrong
sum of array
vjache edited a comment on issue #17143: Wrong sum of array
URL: https://github.com/apache/incubator-mxnet/issues/17143#issuecomment-568257313
> Hi @vjache , it is not a bug.
> The reason is that the default data type is `float64` in numpy, but `float32` in MXNet.
>
> ```python
> >>> import numpy as np
> >>> import mxnet.ndarray as md
> >>> a = [1.0504983e+07, 1.0000000e+00, 2.0000000e+00, 3.0000000e+00, 5.0000000e-01, 1.0000000e+01,
> ... 0.0000000e+00, 0.0000000e+00, 0.0000000e+00, 0.0000000e+00, 0.0000000e+00, 0.0000000e+00]
> >>> np.array(a).dtype, np.array(a).sum()
> (dtype('float64'), 10504999.5)
> >>> md.array(a).dtype, md.array(a).sum()
> (<class 'numpy.float32'>,
> [10505000.]
> <NDArray 1 @cpu(0)>)
> >>> np.array(a, dtype=np.float32).sum()
> 10505000.0
> >>> md.array(a, dtype=np.float64).sum()
>
> [10504999.5]
> <NDArray 1 @cpu(0)>
> ```
Sorry, I've seen your response only after I posted my where I found the bypass. But still I consider this is a serious thing. If I create an array and the accuracy is lost then I should be at least warned, and at best the error raised. It is incorrect to silently do decreasing of accuracy when I create array.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services