megengine.functional.logical_not¶
- logical_not(x)[源代码]¶
 Element-wise logical NOT.
Computes the logical NOT for each element \(x_i\) of the input tensor \(x\).
- 参数
 x – input tensor. Should have a boolean data type.
- 返回
 a tensor containing the result of the element-wise logical NOT operation. The returned tensor must have a data type of
bool.
实际案例
>>> 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_andon boolean tensors.>>> ~x Tensor([False True False], dtype=bool, device=xpux:0)