torch.ldexp¶
- torch.ldexp(input, other, *, out=None) Tensor ¶
将
input
乘以 2 的other
次方。通常这个函数用于通过将
input
中的尾数相乘,并与由other
中的指数创建的 2 的整数次幂相乘来构造浮点数。- 参数:
input (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.])