mindspore.ops.neg

mindspore.ops.neg(input)[source]

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

\[out_{i} = - input_{i}\]
Parameters

input (Tensor) – The input tensor with a dtype of Number.

Returns

Tensor, has the same shape and dtype as input.

Raises

TypeError – If input is not a Tensor.

Supported Platforms:

Ascend GPU CPU

Examples

>>> input = Tensor(np.array([1, 2, -1, 2, 0, -3.5]), mindspore.float32)
>>> output = ops.neg(input)
>>> print(output)
[-1.  -2.   1.  -2.   0.   3.5]