PyTorch torch.lerp function
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
)
(
"Interpolation result:"
,
result
)
The output is:
插值结果: tensor([ 5., 10.])