Skip to content

Commit 3cf6116

Browse files
authored
Fix auto-compression demo (PaddlePaddle#1035)
* fix * fix ac demo
1 parent 8386960 commit 3cf6116

File tree

7 files changed

+17
-11
lines changed

7 files changed

+17
-11
lines changed

demo/auto-compression/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ python tools/export_model.py \
5454
```
5555
cd PaddleSlim/demo/auto-compression/
5656
```
57-
使用[eval.py](../quant_post/eval.py)脚本得到模型的分类精度:
57+
使用[eval.py](../quant/quant_post/eval.py)脚本得到模型的分类精度:
5858
```
59-
python ../quant_post/eval.py --model_path infermodel_mobilenetv2 --model_name inference.pdmodel --params_name inference.pdiparams
59+
python ../quant/quant_post/eval.py --model_path infermodel_mobilenetv2 --model_name inference.pdmodel --params_name inference.pdiparams
6060
```
6161
精度输出为:
6262
```

demo/auto-compression/configs/CV/mbv2_qat_dis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Distillation:
4141
- teacher_linear_1.tmp_0
4242
- linear_1.tmp_0
4343
merge_feed: true
44-
teacher_model_dir: ./MobileNetV2_ssld_infer
44+
teacher_model_dir: ./infermodel_mobilenetv2
4545
teacher_model_filename: inference.pdmodel
4646
teacher_params_filename: inference.pdiparams
4747
Quantization:

demo/auto-compression/configs/NLP/bert_asp_dis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Distillation:
2929
- teacher_linear_147.tmp_1
3030
- linear_147.tmp_1
3131
merge_feed: true
32-
teacher_model_dir: ../auto-compression_origin/static_bert_models
32+
teacher_model_dir: static_bert_models
3333
teacher_model_filename: bert.pdmodel
3434
teacher_params_filename: bert.pdiparams
3535
Prune:

demo/auto-compression/run_gelu.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
python3.7 demo_glue.py --config_path ./configs/NLP/bert_qat_dis.yaml --task 'sst-2' \
2-
--model_dir='../auto-compression_origin/static_bert_models/' \
1+
python3.7 demo_glue.py \
2+
--model_dir='./static_bert_models/' \
33
--model_filename='bert.pdmodel' \
44
--params_filename='bert.pdiparams' \
55
--save_dir='./save_asp_bert/' \
6-
--devices='gpu' \
6+
--devices='cpu' \
77
--batch_size=32 \
8+
--task='sst-2' \
9+
--config_path='./configs/NLP/bert_asp_dis.yaml'
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
python3.7 demo_imagenet.py --config_path ./configs/CV/mbv2_ptq_hpo.yaml \
2-
--model_dir='../auto-compression_origin/MobileNetV2_ssld_infer/' \
1+
python3.7 demo_imagenet.py \
2+
--model_dir='infermodel_mobilenetv2' \
33
--model_filename='inference.pdmodel' \
44
--params_filename='./inference.pdiparams' \
55
--save_dir='./save_qat_mbv2/' \
6-
--devices='gpu' \
7-
--batch_size=64 \
6+
--devices='cpu' \
7+
--batch_size=2 \
8+
--config_path='./configs/CV/mbv2_ptq_hpo.yaml'

demo/quant/quant_post/eval.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import paddle
2222
sys.path[0] = os.path.join(
2323
os.path.dirname("__file__"), os.path.pardir, os.path.pardir)
24+
sys.path[1] = os.path.join(
25+
os.path.dirname("__file__"), os.path.pardir)
2426
import imagenet_reader as reader
2527
from utility import add_arguments, print_arguments
2628

paddleslim/auto_compression/compressor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ def compress(self):
276276

277277
### used to check whether the dataloader is right
278278
if self.eval_function is not None and self.train_config.origin_metric is not None:
279+
_logger.info("start to test metric before compress")
279280
metric = self.eval_function(self._exe, inference_program,
280281
feed_target_names, fetch_targets)
281282
_logger.info("metric of compressed model is: {}".format(metric))

0 commit comments

Comments
 (0)