Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.log1p function

PyTorch torch.log1p function


PyTorch torch reference manual 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

)

print

(

"log(1+x):"

,

y

)

The output is:

log(1+x): tensor([0.0000, 0.4055, 0.6931, 1.0986])


PyTorch torch reference manual PyTorch torch reference manual