PyTorch torch.log1p Function
Pytorch torch Reference Manual
torch.log1pIt is a function in PyTorch used to compute log(1+x), and is more accurate for values close to zero.
Function Definition
torch.log1p(input, out=None)
Usage Example
Example
import torch
# Compute log(1+x)
x = torch.tensor([0.0, 0.5, 1.0, 2.0])
y = torch.log1p(x)
print("log(1+x):", y)
# Compute log(1+x)
x = torch.tensor([0.0, 0.5, 1.0, 2.0])
y = torch.log1p(x)
print("log(1+x):", y)
The output result is:
log(1+x): tensor([0.0000, 0.4055, 0.6931, 1.0986])
Other Extensions