mindspore.Tensor.logical_xor
- Tensor.logical_xor(other) Tensor
Computes the "logical XOR" of two tensors element-wise.
\[out_{i} = self_{i} \oplus other_{i}\]Note
self and other comply with the type conversion rules to make the data types consistent.
When the other is bool, it could only be a constant.
- Parameters
other (Union[Tensor, bool]) – A bool or a tensor whose data type can be implicitly converted to bool.
- Returns
Tensor, the shape is the same as the self and other after broadcasting, and the data type is bool.
- Supported Platforms:
Ascend
CPU
Examples
>>> import mindspore >>> import numpy as np >>> from mindspore import Tensor >>> input = Tensor(np.array([True, False, True]), mindspore.bool_) >>> other = Tensor(np.array([True, True, False]), mindspore.bool_) >>> output = input.logical_xor(other) >>> print(output) [ False True True] >>> x = Tensor(1, mindspore.bool_) >>> other = Tensor(0, mindspore.bool_) >>> output = input.logical_xor(other) >>> print(output) True