PyTorch torch.ldexp 関数


Pytorch torch 参考手册Pytorch torch リファレンスマニュアル

torch.ldexpPyTorch において、仮数と2の指数乗を掛け合わせるための関数であり、frexp の逆操作です。

関数定義

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

使用例

実例

import torch

# frexp を使用して分解
x = torch.tensor([8.0, 4.5, 2.0])
mantissa, exponent = torch.frexp(x)

# ldexp を使用して再構築
reconstructed = torch.ldexp(mantissa, exponent)
print("再構築値:", reconstructed)

出力結果は次のとおりです:

重建值: tensor([8., 4.5, 2.])

Pytorch torch 参考手册Pytorch torch リファレンスマニュアル

その他の拡張