ZheyuYe opened a new issue #18068: [Numpy] Failed for Boolean type URL: https://github.com/apache/incubator-mxnet/issues/18068 ## Description Many operations are unreliable in numpy interface but works well in `mx.nd.ndarray`, such as an example showcased in the reproducible code snippet. The reasons for the above problems can be boiled down to the incompatibility of **Boolean type** which is the return type of `mx.np.equal'. Unlike the `mx.np.equal` operation, `mx.nd.equal` takes float32 as the resulting data type and works fine in this case. ## To Reproduce ``` import mxnet as mx inputs = mx.np.array([1,1,1]) fake_data = mx.np.array([1,1,0]) 1 - mx.np.equal(fake_data, inputs) inputs = mx.nd.array([1,1,1]) fake_data = mx.nd.array([1,1,0]) 1 - mx.nd.equal(fake_data, inputs) ``` ### Error Message ``` MXNetError Traceback (most recent call last) /usr/local/lib/python3.6/dist-packages/IPython/core/formatters.py in __call__(self, obj) 700 type_pprinters=self.type_printers, 701 deferred_pprinters=self.deferred_printers) --> 702 printer.pretty(obj) 703 printer.flush() 704 return stream.getvalue() /usr/local/lib/python3.6/dist-packages/IPython/lib/pretty.py in pretty(self, obj) 400 if cls is not object \ 401 and callable(cls.__dict__.get('__repr__')): --> 402 return _repr_pprint(obj, self, cycle) 403 404 return _default_pprint(obj, self, cycle) /usr/local/lib/python3.6/dist-packages/IPython/lib/pretty.py in _repr_pprint(obj, p, cycle) 695 """A pprint that just redirects to the normal repr function.""" 696 # Find newlines and replace them with p.break_() --> 697 output = repr(obj) 698 for idx,output_line in enumerate(output.splitlines()): 699 if idx: ~/mxnet/python/mxnet/numpy/multiarray.py in __repr__(self) 1163 [0.84426576 0.60276335 0.85794562]] @gpu(0) 1164 """ -> 1165 array_str = self.asnumpy().__repr__() 1166 dtype = self.dtype 1167 if 'dtype=' in array_str: ~/mxnet/python/mxnet/ndarray/ndarray.py in asnumpy(self) 2564 self.handle, 2565 data.ctypes.data_as(ctypes.c_void_p), -> 2566 ctypes.c_size_t(data.size))) 2567 return data 2568 ~/mxnet/python/mxnet/base.py in check_call(ret) 244 """ 245 if ret != 0: --> 246 raise get_last_ffi_error() 247 248 MXNetError: Traceback (most recent call last): File "../src/operator/numpy/./../tensor/elemwise_binary_scalar_op.h", line 244 MXNetError: Unknown type enum 7 ``` ## Comments @sxjscience
---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
