fn

log1p

Tensor
log1p(input: Tensor)
source

Element-wise natural logarithm of 1 + x.

Numerically accurate for small x where log(1 + x) loses precision.

Parameters

inputTensor
Input tensor.

Returns

Tensor

Element-wise result with the same shape as input.

Notes

Mathematical definition:

outi=ln(1+inputi),inputi>1\text{out}_i = \ln(1 + \text{input}_i), \quad \text{input}_i > -1

Gradient: 1/(1+x)1 / (1 + x). Preferred over log(1 + x) near zero.

Examples

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