2 Star 2 Fork 1

openvinotoolkit-prc / nncf

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 1.44 KB
一键复制 编辑 原始数据 按行查看 历史

Quantization-Aware Training: An Example for Resnet18 in PyTorch

This example demonstrates how to use Post-Training Quantization API from Neural Network Compression Framework (NNCF) to quantize and train PyTorch models on the example of Resnet18 quantization aware training, pretrained on Tiny ImageNet-200 dataset.

The example includes the following steps:

  • Loading the Tiny ImageNet-200 dataset (~237 Mb) and the Resnet18 PyTorch model pretrained on this dataset.
  • Quantizing the model using NNCF Post-Training Quantization algorithm.
  • Fine tuning quantized model for one epoch to improve quantized model metrics.
  • Output of the following characteristics of the quantized model:
    • Accuracy drop of the quantized model (INT8) over the pre-trained model (FP32)
    • Compression rate of the quantized model file size relative to the pre-trained model file size
    • Performance speed up of the quantized model (INT8)

Install requirements

At this point it is assumed that you have already installed NNCF. You can find information on installation NNCF here.

To work with the example you should install the corresponding Python package dependencies:

pip install -r requirements.txt

Run Example

It's pretty simple. The example does not require additional preparation. It will do the preparation itself, such as loading the dataset and model, etc.

python main.py
Python
1
https://gitee.com/openvinotoolkit-prc/nncf.git
git@gitee.com:openvinotoolkit-prc/nncf.git
openvinotoolkit-prc
nncf
nncf
develop

搜索帮助