-
Notifications
You must be signed in to change notification settings - Fork 798
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding pytorch quantized sparsified aware training
- Loading branch information
1 parent
9f2e681
commit 0524d93
Showing
5 changed files
with
834 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
notebooks/pytorch-quantization-sparsity-aware-training/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Optimizing PyTorch models with Neural Network Compression Framework of OpenVINO™ by 8-bit quantization. | ||
|
||
This tutorial demonstrates how to use [NNCF](https://github.com/openvinotoolkit/nncf) 8-bit sparse quantization to optimize the | ||
[PyTorch](https://pytorch.org/) model for inference with [OpenVINO Toolkit](https://docs.openvino.ai/). | ||
For more advanced usage, refer to these [examples](https://github.com/openvinotoolkit/nncf/tree/develop/examples). | ||
|
||
This notebook is based on 'ImageNet training in PyTorch' [example](https://github.com/pytorch/examples/blob/master/imagenet/main.py). | ||
This notebook uses a [ResNet-50](https://arxiv.org/abs/1512.03385) model with the | ||
ImageNet dataset. | ||
|
||
## Notebook Contents | ||
|
||
This tutorial consists of the following steps: | ||
* Transforming the original dense `FP32` model to sparse `INT8` | ||
* Using fine-tuning to restore the accuracy. | ||
* Exporting optimized and original models to OpenVINO | ||
* Measuring and comparing the performance of the models. | ||
|
||
## Installation Instructions | ||
|
||
This is a self-contained example that relies solely on its own code and accompanying config.json file.</br> | ||
We recommend running the notebook in a virtual environment. You only need a Jupyter server to start. | ||
For details, please refer to [Installation Guide](../../README.md). | ||
|
36 changes: 36 additions & 0 deletions
36
notebooks/pytorch-quantization-sparsity-aware-training/config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"target_device": "CPU", | ||
"input_info": { | ||
"sample_size": [ | ||
1, | ||
3, | ||
224, | ||
224 | ||
] | ||
}, | ||
"compression": [ | ||
{ | ||
"algorithm": "magnitude_sparsity", | ||
"sparsity_init": 0, | ||
"params": { | ||
"schedule": "multistep", | ||
"sparsity_freeze_epoch": 5, | ||
"multistep_steps": [2], | ||
"multistep_sparsity_levels": [0.3, 0.5] | ||
}, | ||
"ignored_scopes": [ | ||
"ResNet/NNCFConv2d[conv1]/conv2d_0" | ||
] | ||
}, | ||
{ | ||
"algorithm": "quantization", | ||
"initializer": { | ||
"range": { | ||
"num_init_samples": 10000 | ||
} | ||
}, | ||
"ignored_scopes": [ | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.