Skip to content

Commit

Permalink
Fix load checkpoint (PaddlePaddle#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
slf12 authored Feb 22, 2020
1 parent 61a8b0e commit 3849c17
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 249 deletions.
2 changes: 1 addition & 1 deletion slim/quantization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ python slim/quantization/train.py --not_quant_pattern yolo_output \


通过`python slim/quantization/train.py --help`查看可配置参数。
通过`python .tools/configure.py ${option_name} help`查看如何通过命令行覆盖配置文件中的参数。
通过`python ./tools/configure.py help ${option_name}`查看如何通过命令行覆盖配置文件中的参数。



Expand Down
1 change: 0 additions & 1 deletion slim/quantization/export_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from paddle import fluid

from ppdet.core.workspace import load_config, merge_config, create
from ppdet.modeling.model_input import create_feed
from ppdet.utils.cli import ArgsParser
import ppdet.utils.checkpoint as checkpoint
from tools.export_model import prune_feed_vars
Expand Down
239 changes: 0 additions & 239 deletions slim/quantization/freeze.py

This file was deleted.

20 changes: 12 additions & 8 deletions slim/quantization/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,15 @@ def main():

fuse_bn = getattr(model.backbone, 'norm_type', None) == 'affine_channel'

if FLAGS.resume_checkpoint:
checkpoint.load_checkpoint(exe, train_prog, FLAGS.resume_checkpoint)
start_iter = checkpoint.global_step()
elif cfg.pretrain_weights and fuse_bn and not ignore_params:
checkpoint.load_and_fusebn(exe, train_prog, cfg.pretrain_weights)
elif cfg.pretrain_weights:
checkpoint.load_params(
exe, train_prog, cfg.pretrain_weights, ignore_params=ignore_params)
if not FLAGS.resume_checkpoint:
if cfg.pretrain_weights and fuse_bn and not ignore_params:
checkpoint.load_and_fusebn(exe, train_prog, cfg.pretrain_weights)
elif cfg.pretrain_weights:
checkpoint.load_params(
exe,
train_prog,
cfg.pretrain_weights,
ignore_params=ignore_params)
# insert quantize op in train_prog, return type is CompiledProgram
train_prog = quant_aware(train_prog, place, config, for_test=False)

Expand All @@ -189,6 +190,9 @@ def main():
compiled_eval_prog = fluid.compiler.CompiledProgram(eval_prog)

start_iter = 0
if FLAGS.resume_checkpoint:
checkpoint.load_checkpoint(exe, eval_prog, FLAGS.resume_checkpoint)
start_iter = checkpoint.global_step()

train_reader = create_reader(cfg.TrainReader,
(cfg.max_iters - start_iter) * devices_num)
Expand Down

0 comments on commit 3849c17

Please sign in to comment.