larroy commented on issue #8668: Precision error setting NDArray from 
np.float32 scalar
URL: 
https://github.com/apache/incubator-mxnet/issues/8668#issuecomment-363495288
 
 
   This is failing in Raspberry PI
   
   ```
   In [1]: import mxnet as mx
   
   In [2]: a = np.array([47.844944], dtype=np.float32)
   ---------------------------------------------------------------------------
   NameError                                 Traceback (most recent call last)
   <ipython-input-2-2b457ab00a8d> in <module>()
   ----> 1 a = np.array([47.844944], dtype=np.float32)
   
   NameError: name 'np' is not defined
   
   In [3]: import numpy as np
   
   In [4]: a = np.array([47.844944], dtype=np.float32)
   
   In [5]: a
   Out[5]: array([ 47.844944], dtype=float32)
   
   In [6]: b = mx.nd.zeros(1, dtype=np.float32)
   
   In [7]: b[0] = a
   
   In [8]: b
   Out[8]:
   
   [ 47.844944]
   <NDArray 1 @cpu(0)>
   
   In [9]: a
   Out[9]: array([ 47.844944], dtype=float32)
   
   In [10]: same(a, b.asnumpy())
   ---------------------------------------------------------------------------
   NameError                                 Traceback (most recent call last)
   <ipython-input-10-d87907b2910b> in <module>()
   ----> 1 same(a, b.asnumpy())
   
   NameError: name 'same' is not defined
   
   In [11]: from mxnet.test_utils import same
   
   In [12]: same(a, b.asnumpy())
   Out[12]: True
   
   In [13]: b
   Out[13]:
   
   [ 47.844944]
   <NDArray 1 @cpu(0)>
   
   In [14]: b[0] = a[0]
   ---------------------------------------------------------------------------
   AttributeError                            Traceback (most recent call last)
   <ipython-input-14-121523e9a993> in <module>()
   ----> 1 b[0] = a[0]
   
   ~/mxnet/python/mxnet/ndarray/ndarray.py in __setitem__(self, key, value)
       435         indexing_dispatch_code = _get_indexing_dispatch_code(key)
       436         if indexing_dispatch_code == _NDARRAY_BASIC_INDEXING:
   --> 437             self._set_nd_basic_indexing(key, value)
       438         elif indexing_dispatch_code == _NDARRAY_ADVANCED_INDEXING:
       439             self._set_nd_advanced_indexing(key, value)
   
   ~/mxnet/python/mxnet/ndarray/ndarray.py in _set_nd_basic_indexing(self, key, 
value)
       677         if isinstance(key, integer_types):
       678             sliced_arr = self._at(key)
   --> 679             sliced_arr[:] = value
       680             return
       681         elif isinstance(key, py_slice):
   
   ~/mxnet/python/mxnet/ndarray/ndarray.py in __setitem__(self, key, value)
       435         indexing_dispatch_code = _get_indexing_dispatch_code(key)
       436         if indexing_dispatch_code == _NDARRAY_BASIC_INDEXING:
   --> 437             self._set_nd_basic_indexing(key, value)
       438         elif indexing_dispatch_code == _NDARRAY_ADVANCED_INDEXING:
       439             self._set_nd_advanced_indexing(key, value)
   
   ~/mxnet/python/mxnet/ndarray/ndarray.py in _set_nd_basic_indexing(self, key, 
value)
       691                         value.copyto(self)
       692                 elif isinstance(value, numeric_types):
   --> 693                     _internal._full(shape=shape, ctx=self.context,
       694                                     dtype=self.dtype, 
value=float(value), out=self)
       695                 elif isinstance(value, (np.ndarray, np.generic)):
   
   AttributeError: module 'mxnet.ndarray._internal' has no attribute '_full'
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to