kalpitdixit opened a new issue #15334: boolean_mask operator fails when all 
masks are 0
URL: https://github.com/apache/incubator-mxnet/issues/15334
 
 
    Check failed: valid_num > 0: boolean_mask behavior not defined when all 
masks are 0
   This is limiting me from using this operator and making me implement several 
if-else conditions in my code.
   
   Equivalent TensorFlow operator works by returning an empty array which solve 
the problem.
   https://www.tensorflow.org/api_docs/python/tf/boolean_mask
   
   **Issue and Reproducible Code**
   ```python
   >>> from mxnet.ndarray.contrib import boolean_mask
   >>> import mxnet.ndarray as F
   >>> a = F.arange(4)
   >>> b = F.array([0,1,0,0])
   >>> c = F.array([0,0,0,0])
   >>> boolean_mask(a,b)
   
   [ 1.]
   <NDArray 1 @cpu(0)>
   >>> boolean_mask(a,c)
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "/usr/local/lib/python3.5/dist-packages/mxnet/ndarray/ndarray.py", 
line 194, in __repr__
       return '\n%s\n<%s %s @%s>' % (str(self.asnumpy()),
     File "/usr/local/lib/python3.5/dist-packages/mxnet/ndarray/ndarray.py", 
line 1996, in asnumpy
       ctypes.c_size_t(data.size)))
     File "/usr/local/lib/python3.5/dist-packages/mxnet/base.py", line 253, in 
check_call
       raise MXNetError(py_str(_LIB.MXGetLastError()))
   mxnet.base.MXNetError: [15:16:38] include/mxnet/./tuple.h:477: Check failed: 
ndim_is_known(this->ndim()): Shape is unknown.
   Stack trace:
     [bt] (0) 
/usr/local/lib/python3.5/dist-packages/mxnet/libmxnet.so(+0x4ac86b) 
[0x7fc9ef1f886b]
     [bt] (1) 
/usr/local/lib/python3.5/dist-packages/mxnet/libmxnet.so(+0x4fd033) 
[0x7fc9ef249033]
     [bt] (2) 
/usr/local/lib/python3.5/dist-packages/mxnet/libmxnet.so(mxnet::NDArray::SyncCopyToCPU(void*,
 unsigned long) const+0x54) [0x7fc9f14f8d84]
     [bt] (3) 
/usr/local/lib/python3.5/dist-packages/mxnet/libmxnet.so(MXNDArraySyncCopyToCPU+0x2b)
 [0x7fc9f126381b]
     [bt] (4) 
/usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so(ffi_call_unix64+0x4c)
 [0x7fca32baae20]
     [bt] (5) 
/usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so(ffi_call+0x2eb)
 [0x7fca32baa88b]
     [bt] (6) 
/usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so(_ctypes_callproc+0x49a)
 [0x7fca32ba501a]
     [bt] (7) 
/usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so(+0x9fcb) 
[0x7fca32b98fcb]
     [bt] (8) python3.5(PyObject_Call+0x47) [0x5c20e7]
   ```

----------------------------------------------------------------
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

Reply via email to