mindspore.ops.Neg

View Source On Gitee
class mindspore.ops.Neg[source]

Returns a tensor with negative values of the input tensor element-wise.

Refer to mindspore.ops.neg() for more details.

Inputs:
  • x (Tensor) - The input tensor whose dtype is Number.

Outputs:

Tensor, has the same shape and dtype as input.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> neg = ops.Neg()
>>> x = Tensor(np.array([1, 2, -1, 2, 0, -3.5]), mindspore.float32)
>>> output = neg(x)
>>> print(output)
[-1.  -2.   1.  -2.   0.   3.5]