megengine.functional.logical_not¶
- logical_not(x)[source]¶
Element-wise logical NOT.
Computes the logical NOT for each element \(x_i\) of the input tensor \(x\).
- Parameters
x – input tensor. Should have a boolean data type.
- Returns
a tensor containing the result of the element-wise logical NOT operation. The returned tensor must have a data type of
bool
.
See also
Examples
>>> F.logical_not(True) Tensor(False, dtype=bool, device=xpux:0)
Element-wise logical NOT:
>>> x = Tensor([True, False, True]) >>> F.logical_not(x) Tensor([False True False], dtype=bool, device=xpux:0)
The
~
operator can be used as a shorthand forF.logical_and
on boolean tensors.>>> ~x Tensor([False True False], dtype=bool, device=xpux:0)