PyTorch torch.ldexp 関数
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)
# 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 リファレンスマニュアル