量子化

term_id: quantization

Category: training_techniques

Definition

量子化は、高精度な浮動小数点数(例:FP32)を低精度フォーマット(例:INT8やFP16)に変換します。この精度の低下により、モデルのメモリ使用量と計算要件が減少し、推論速度が向上します。

Summary

ニューラルネットワーク計算で使用される数値の精度を下げ、モデルサイズを縮小し、速度を向上させるモデル最適化技術。

Key Concepts

  • 精度の削減
  • 推論速度
  • メモリ最適化
  • INT8/FP16

Use Cases

  • エッジデバイスへのデプロイ
  • モバイルAIアプリケーション
  • リアルタイム推論

Code Example

1
2
3
4
5
6
import torch.quantization as quant
# Example of converting a model to quantized format
model.eval()
model.qconfig = quant.get_default_qconfig('fbgemm')
quantized_model = quant.prepare(model, inplace=False)
quantized_model = quant.convert(quantized_model, inplace=False)