mindspore.mint.neg

View Source On Gitee
mindspore.mint.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

Examples

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