torch.lerp#
- torch.lerp(input, end, weight, *, out=None)#
對兩個張量
start(由input指定)和end進行線性插值,插值基於一個標量或張量weight,並返回結果out張量。start和end的形狀必須是 可廣播的。如果weight是一個張量,那麼weight、start和end的形狀必須是 可廣播的。- 引數
- 關鍵字引數
out (Tensor, optional) – 輸出張量。
示例
>>> 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])