Skip to content
fn

negative

→Tensor
negative(input: Tensor)

Element-wise negation.

Verbose alias of lucid.neg. Equivalent to the unary - operator on a tensor.

Parameters

inputTensor
Input tensor. Any numeric dtype.

Returns

Tensor

Tensor of the same shape and dtype as input whose entries are −xi-x_i.

Notes

Mathematical definition:

outi=−xi\text{out}_i = -x_i

The gradient with respect to input is −1-1 everywhere.

Examples

>>> import lucid
>>> x = lucid.tensor([1.0, -2.0, 3.5])
>>> lucid.negative(x)
tensor([-1., 2., -3.5])