評價此頁

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 中的指數生成的整數次冪相乘來構造浮點數。

引數
  • 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.])