mindspore.Tensor.less
- mindspore.Tensor.less(other)
逐元素计算
,返回为bool。self 和 other 的输入遵循隐式类型转换规则,使数据类型一致。 当 other 是一个Scalar时,只能是一个常量。
- 参数:
other (Union[Tensor, Number, bool]) - 待比较的值。支持数值型、bool或Tensor[Number/bool]。
- 返回:
Tensor,输出shape与广播后的shape相同,数据类型为bool。
- 异常:
TypeError - 如果 self 和 other 不是以下之一:Tensor、数值型、bool。
- 支持平台:
Ascend
GPU
CPU
样例:
>>> import mindspore >>> import numpy as np >>> from mindspore import Tensor >>> input = Tensor(np.array([1, 2, 3]), mindspore.int32) >>> other = Tensor(np.array([1, 1, 4]), mindspore.int32) >>> output = input.less(other) >>> print(output) [False False True]