捷徑

torch.ldexp

torch.ldexp(input, other, *, out=None) Tensor

input 乘以 2 ** other

outi=inputi2iother\text{{out}}_i = \text{{input}}_i * 2^\text{{other}}_i

通常,此函數用於透過將 input 中的假數乘以來自 other 中指數的 2 的整數次方來構造浮點數。

參數
  • input (Tensor) – 輸入張量。

  • other (Tensor) – 指數的張量,通常為整數。

關鍵字引數

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

範例

>>> torch.ldexp(torch.tensor([1.]), torch.tensor([1]))
tensor([2.])
>>> torch.ldexp(torch.tensor([1.0]), torch.tensor([1, 2, 3, 4]))
tensor([ 2.,  4.,  8., 16.])

文件

存取 PyTorch 的全面開發人員文件

檢視文件

教學課程

取得初學者和進階開發人員的深入教學課程

檢視教學課程

資源

尋找開發資源並獲得問題解答

檢視資源