PyTorch torch.dequantize 関数
torch.dequantize量子化テンソルを浮動小数点テンソルに逆量子化するための PyTorch の関数です。
関数定義
torch.dequantize(input)
使用例
実例
import torch
# 入力テンソルを作成
input = torch.tensor([[-1.0, 0.0], [1.0, 2.0]])
# 量子化テンソル
quantized = torch.quantize_per_tensor(input, scale=0.1, zero_point=10, dtype=torch.quint8)
print("量子化テンソル:")
print(quantized)
# 逆量子化
x = torch.dequantize(quantized)
print("逆量子化後の浮動小数点テンソル:")
print(x)
# 入力テンソルを作成
input = torch.tensor([[-1.0, 0.0], [1.0, 2.0]])
# 量子化テンソル
quantized = torch.quantize_per_tensor(input, scale=0.1, zero_point=10, dtype=torch.quint8)
print("量子化テンソル:")
print(quantized)
# 逆量子化
x = torch.dequantize(quantized)
print("逆量子化後の浮動小数点テンソル:")
print(x)
その他の拡張
Pytorch torch リファレンスマニュアル