fn

negative

Tensor
negative(x: Tensor)
source

Element-wise negation.

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

Parameters

xTensor
Input tensor. Any numeric dtype.

Returns

Tensor

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

Notes

Mathematical definition:

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

The gradient with respect to x is 1-1 everywhere.

Examples

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