megengine.functional.neg#
- neg(x)[source]#
Element-wise negation.
Computes the numerical negative of each element \(x_i\) (i.e., \(y_i = -x_i\) ) of the input tensor \(x\).
- Parameters:
x (
Tensor
) – input tensor. Should have a numeric data type.- Return type:
- Returns:
A tensor containing the evaluated result for each element in \(x\). The returned tensor must have a data type determined by Type promotion rules.
Note
The unary
-
operator can be used as a shorthand forneg
on tensors.Examples
>>> x = Tensor([1, -1]) >>> F.neg(x) Tensor([-1 1], dtype=int32, device=xpux:0)