mindspore.ops.ne

查看源文件
mindspore.ops.ne(input, other)[源代码]

逐元素计算两个输入是否不相等。

outi={True, if inputiotheriFalse, if inputi=otheri

说明

  • 支持隐式类型转换。

  • 当输入是两个Tensor时,它们的shape可以广播。

  • 当输入是一个Tensor和一个Scalar时,Scalar只能是一个常数。

  • 支持广播。

参数:
  • input (Union[Tensor, Number, bool]) - 第一个输入。

  • other (Union[Tensor, Number, bool]) - 第二个输入。

返回:

Tensor

支持平台:

Ascend GPU CPU

样例:

>>> import mindspore
>>> # case 1: The shape of two inputs are different
>>> input = mindspore.tensor([1, 2, 3], mindspore.float32)
>>> output = mindspore.ops.ne(input, 2.0)
>>> print(output)
[True False  True]
>>> # case 2: The shape of two inputs are the same
>>> input = mindspore.tensor([1, 2, 3], mindspore.int32)
>>> other = mindspore.tensor([1, 2, 4], mindspore.int32)
>>> output = mindspore.ops.ne(input, other)
>>> print(output)
[ False False  True]