mindspore.ops.Neg
- class mindspore.ops.Neg(*args, **kwargs)[source]
Returns a tensor with negative values of the input tensor element-wise.
\[out_{i} = - x_{i}\]- Inputs:
x (Tensor) - The input tensor whose dtype is number. \((N,*)\) where \(*\) means ,any number of additional dimensions, its rank should less than 8.
- Outputs:
Tensor, has the same shape and dtype as input.
- Raises
TypeError – If x is not a Tensor.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> 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]