未验证 提交 3cf61169 编写于 作者: C ceci3 提交者: GitHub

Fix auto-compression demo (#1035)

* fix

* fix ac demo
上级 83869609
......@@ -54,9 +54,9 @@ python tools/export_model.py \
```
cd PaddleSlim/demo/auto-compression/
```
使用[eval.py](../quant_post/eval.py)脚本得到模型的分类精度:
使用[eval.py](../quant/quant_post/eval.py)脚本得到模型的分类精度:
```
python ../quant_post/eval.py --model_path infermodel_mobilenetv2 --model_name inference.pdmodel --params_name inference.pdiparams
python ../quant/quant_post/eval.py --model_path infermodel_mobilenetv2 --model_name inference.pdmodel --params_name inference.pdiparams
```
精度输出为:
```
......
......@@ -41,7 +41,7 @@ Distillation:
- teacher_linear_1.tmp_0
- linear_1.tmp_0
merge_feed: true
teacher_model_dir: ./MobileNetV2_ssld_infer
teacher_model_dir: ./infermodel_mobilenetv2
teacher_model_filename: inference.pdmodel
teacher_params_filename: inference.pdiparams
Quantization:
......
......@@ -29,7 +29,7 @@ Distillation:
- teacher_linear_147.tmp_1
- linear_147.tmp_1
merge_feed: true
teacher_model_dir: ../auto-compression_origin/static_bert_models
teacher_model_dir: static_bert_models
teacher_model_filename: bert.pdmodel
teacher_params_filename: bert.pdiparams
Prune:
......
python3.7 demo_glue.py --config_path ./configs/NLP/bert_qat_dis.yaml --task 'sst-2' \
--model_dir='../auto-compression_origin/static_bert_models/' \
python3.7 demo_glue.py \
--model_dir='./static_bert_models/' \
--model_filename='bert.pdmodel' \
--params_filename='bert.pdiparams' \
--save_dir='./save_asp_bert/' \
--devices='gpu' \
--devices='cpu' \
--batch_size=32 \
--task='sst-2' \
--config_path='./configs/NLP/bert_asp_dis.yaml'
python3.7 demo_imagenet.py --config_path ./configs/CV/mbv2_ptq_hpo.yaml \
--model_dir='../auto-compression_origin/MobileNetV2_ssld_infer/' \
python3.7 demo_imagenet.py \
--model_dir='infermodel_mobilenetv2' \
--model_filename='inference.pdmodel' \
--params_filename='./inference.pdiparams' \
--save_dir='./save_qat_mbv2/' \
--devices='gpu' \
--batch_size=64 \
--devices='cpu' \
--batch_size=2 \
--config_path='./configs/CV/mbv2_ptq_hpo.yaml'
......@@ -21,6 +21,8 @@ import functools
import paddle
sys.path[0] = os.path.join(
os.path.dirname("__file__"), os.path.pardir, os.path.pardir)
sys.path[1] = os.path.join(
os.path.dirname("__file__"), os.path.pardir)
import imagenet_reader as reader
from utility import add_arguments, print_arguments
......
......@@ -276,6 +276,7 @@ class AutoCompression:
### used to check whether the dataloader is right
if self.eval_function is not None and self.train_config.origin_metric is not None:
_logger.info("start to test metric before compress")
metric = self.eval_function(self._exe, inference_program,
feed_target_names, fetch_targets)
_logger.info("metric of compressed model is: {}".format(metric))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册