评价此页

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