torch / torch
torch.lerp¶
-
torch.
lerp
(input, end, weight, *, out=None)¶ Does a linear interpolation of two tensors
start
(given byinput
) andend
based on a scalar or tensorweight
and returns the resultingout
tensor.The shapes of
start
andend
must be broadcastable. Ifweight
is a tensor, then the shapes ofweight
,start
, andend
must be broadcastable.- Parameters
- Keyword Arguments
out (Tensor, optional) – the output tensor.
Example:
>>> start = torch.arange(1., 5.) >>> end = torch.empty(4).fill_(10) >>> start tensor([ 1., 2., 3., 4.]) >>> end tensor([ 10., 10., 10., 10.]) >>> torch.lerp(start, end, 0.5) tensor([ 5.5000, 6.0000, 6.5000, 7.0000]) >>> torch.lerp(start, end, torch.full_like(start, 0.5)) tensor([ 5.5000, 6.0000, 6.5000, 7.0000])
此页内容是否对您有帮助