torch.ldexp

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

input乘以 2 的 other 次方。

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

通常,此函数用于通过将 input 中的尾数与从 other 中的指数生成的 2 的整数次幂相乘,来构造浮点数。

参数
  • input (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.])
本页目录