torch.lerp¶
- torch.lerp(input, end, weight, *, out=None)¶
对两个张量
start(由input给出)和end进行线性插值,基于标量或张量weight,并返回结果张量out。start和end的形状必须 可广播。如果weight是一个张量,那么weight、start和end的形状必须 可广播。- Parameters
- Keyword Arguments
输出 (张量, 可选) – 输出张量。
示例:
>>> 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])