快捷方式

torch.lerp

torch.lerp(input, end, weight, *, out=None)

對兩個張量 start (由 input 提供) 和 end 進行線性插值,插值權重基於標量或張量 weight,並返回結果張量 out

outi=starti+weighti×(endistarti)\text{out}_i = \text{start}_i + \text{weight}_i \times (\text{end}_i - \text{start}_i)

startend 的形狀必須是可廣播的。如果 weight 是一個張量,則 weightstartend 的形狀必須是可廣播的

引數
  • input (Tensor) – 起始點張量

  • end (Tensor) – 結束點張量

  • weight (float張量) – 插值公式的權重

關鍵字引數

out (Tensor, 可選) – 輸出張量。

示例

>>> 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])

文件

訪問 PyTorch 的全面開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源