mindspore.ops.ne

mindspore.ops.ne(input, other)[source]

Compute the non-equivalence of two inputs element-wise.

\[\begin{split}out_{i} =\begin{cases} & \text{True, if } input_{i} \ne other_{i} \\ & \text{False, if } input_{i} = other_{i} \end{cases}\end{split}\]

Note

  • Support implicit type conversion.

  • When the inputs are two tensors, the shapes of them could be broadcast.

  • When the inputs are one tensor and one scalar, the scalar could only be a constant.

  • Broadcasting is supported.

Parameters
  • input (Union[Tensor, Number, bool]) – The first input.

  • other (Union[Tensor, Number, bool]) – The second input.

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> 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]