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

PyTorch torch.lerp function

PyTorch torch.lerp function


PyTorch torch reference manual PyTorch torch reference manual

torch.lerp is a function in PyTorch used to compute linear interpolation between two tensors.

Function definition

torch.lerp(input, end, weight, out=None)


Usage examples

Example

import

torch

Create two tensors

start

=

torch.

tensor

(

[

0.0

,

0.0

]

)

end

=

torch.

tensor

(

[

10.0

,

20.0

]

)

Perform linear interpolation at weight=0.5

result

=

torch.

lerp

(

start

,

end

,

0.5

)

print

(

"Interpolation result:"

,

result

)

The output is:

插值结果: tensor([ 5., 10.])


PyTorch torch reference manual PyTorch torch reference manual