diff --git a/slim/quantization/README.md b/slim/quantization/README.md index 48644c1de708e5a84a5ed040abe5144eb7940e77..0db1e37b048e168b59e8edd7c4e025fbd9cf2ea0 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 f8a7d6faefc1c01ae1b7538facaee4cb7b2fad2b..429a92b083a1e5227481602c9bb0759bf71225c4 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