PyTorch torch.lerp Function
Pytorch torch Reference Manual
torch.lerpIt is a function in PyTorch used to compute linear interpolation between two tensors.
Function Definition
torch.lerp(input, end, weight, out=None)
Usage Example
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)
# 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 result is:
插值结果: tensor([ 5., 10.])
Other Extensions