快捷方式

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,可選) – 輸出張量。

示例

>>> 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 的全面開發者文件

檢視文件

教程

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

檢視教程

資源

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

檢視資源