This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
[Numpy] Failed for Boolean type #18068
Comments
import mxnet as mx
inputs = mx.np.array([1,1,1])
fake_data = mx.np.array([1,1,0])
labels = mx.np.ones_like(inputs) - mx.np.equal(fake_data, inputs) It works well. |
We should enhance the support of |
Assignee: @cassinixu |
Thanks for your issue, >>> inputs = torch.tensor([1,1,1])
>>> fake_data = torch.tensor([1,1,0])
>>> 1 - (inputs == fake_data)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/torch/tensor.py", line 394, in __rsub__
return _C._VariableFunctions.rsub(self, other)
RuntimeError: Subtraction, the `-` operator, with a bool tensor is not supported. If you are trying to invert a mask, use the `~` or `logical_not()` operator instead.
>>> If we are capable of providing a solution to this case, that would be a huge advantage over PyTorch. |
7 tasks
closed by #18277 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 ofmx.np.equal'. Unlike the
mx.np.equaloperation,
mx.nd.equal` takes float32 as the resulting data type and works fine in this case.To Reproduce
Error Message
Comments
@sxjscience
The text was updated successfully, but these errors were encountered: