mindspore.Tensor.bool
- Tensor.bool()[source]
Converts input tensor dtype to bool. If the value in tensor is zero, it will be False, otherwise it will be True.
- Returns
Tensor, converted to the bool dtype.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import numpy as np >>> import mindspore >>> from mindspore import Tensor >>> input_x = Tensor(np.ones([2,2]), mindspore.float32) >>> output = input_x.bool() >>> print(output.dtype) Bool