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 的整数次幂相乘,来构造浮点数。示例:
>>> 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.])