negative¶
- paddle. negative ( x: Tensor, name: str | None = None ) Tensor [source]
-
Returns the negated version of the input Tensor. This is used in Tensor.__neg__, applying the unary - operator to the tensor.
\[Out = -X\]- Parameters
-
x (Tensor) – The input tensor. The tensor cannot be of type bool.
name (str|None, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.
- Returns
-
- A tensor with the same shape and data type as the input tensor. The returned tensor
-
is the negative.
- Return type
-
Tensor
Examples
>>> import paddle >>> x = paddle.to_tensor([-1, 0, 1]) >>> out = paddle.negative(x) >>> print(out) Tensor(shape=[3], dtype=int64, place=Place(cpu), stop_gradient=True, [1, 0, -1])