fn

neg

Tensor
neg(input: Tensor)
source

Element-wise negation.

Returns the additive inverse of input. Equivalent to -input.

Parameters

inputTensor
Input tensor.

Returns

Tensor

Element-wise result with the same shape as input.

Notes

Mathematical definition:

outi=inputi\text{out}_i = -\text{input}_i

Gradient: out/input=1\partial \text{out}/\partial \text{input} = -1.

Examples

>>> import lucid
>>> x = lucid.tensor([1.0, 2.0, 3.0])
>>> lucid.neg(x)
Tensor([...])