From d103a9f83a84be9c2945a59b061e6bd1753ba759 Mon Sep 17 00:00:00 2001 From: Guanghua Yu <742925032@qq.com> Date: Wed, 15 Apr 2020 20:05:21 +0800 Subject: [PATCH] fix quant train prog (#509) --- slim/quantization/README.md | 2 ++ slim/quantization/train.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/slim/quantization/README.md b/slim/quantization/README.md index 48644c1de..0db1e37b0 100644 --- a/slim/quantization/README.md +++ b/slim/quantization/README.md @@ -67,6 +67,8 @@ python slim/quantization/train.py --not_quant_pattern yolo_output \ pretrain_weights=https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar ``` +**注意:** 目前量化训练中只支持边训练边评估,所以训练时必需携带`--eval`参数,否则无法训练与保存模型。这个量化中的问题未来会持续改进。 + >通过命令行覆设置max_iters选项,因为量化的训练轮次比正常训练小很多,所以需要修改此选项。 如果要调整训练卡数,可根据需要调整配置文件`yolov3_mobilenet_v1_voc.yml`中的以下参数: diff --git a/slim/quantization/train.py b/slim/quantization/train.py index f8a7d6fae..429a92b08 100644 --- a/slim/quantization/train.py +++ b/slim/quantization/train.py @@ -59,6 +59,10 @@ def load_global_step(exe, prog, path): def main(): + if FLAGS.eval is False: + raise ValueError( + "Currently only supports `--eval==True` while training in `quantization`." + ) env = os.environ FLAGS.dist = 'PADDLE_TRAINER_ID' in env and 'PADDLE_TRAINERS_NUM' in env if FLAGS.dist: @@ -202,7 +206,6 @@ def main(): if FLAGS.eval: # insert quantize op in eval_prog eval_prog = quant_aware(eval_prog, place, config, for_test=True) - compiled_eval_prog = fluid.compiler.CompiledProgram(eval_prog) start_iter = 0 -- GitLab