PyTorch torch.log1p function
PyTorch torch reference manual
torch.log1p is a function in PyTorch used to compute log(1+x), which is more accurate for values close to zero.
Function definition
torch.log1p(input, out=None)
Usage examples
Example
import
torch
Compute log(1+x)
x
=
torch.
tensor
(
[
0.0
,
0.5
,
1.0
,
2.0
]
)
y
=
torch.
log1p
(
x
)
(
"log(1+x):"
,
y
)
The output is:
log(1+x): tensor([0.0000, 0.4055, 0.6931, 1.0986])