From 9dbd3e085a5d989cbebc07502b78e5e908f0dcae Mon Sep 17 00:00:00 2001 From: whs Date: Mon, 10 Jun 2019 20:22:02 +0800 Subject: [PATCH] Add auto pruning demo. (#2326) * Add auto pruning demo. * Fix config file of auto pruning. --- PaddleSlim/configs/auto_prune.yaml | 32 ++++++++++++++++++++++++++++++ PaddleSlim/run.sh | 8 ++++++++ 2 files changed, 40 insertions(+) create mode 100644 PaddleSlim/configs/auto_prune.yaml diff --git a/PaddleSlim/configs/auto_prune.yaml b/PaddleSlim/configs/auto_prune.yaml new file mode 100644 index 00000000..51a8e2f8 --- /dev/null +++ b/PaddleSlim/configs/auto_prune.yaml @@ -0,0 +1,32 @@ +version: 1.0 +pruners: + pruner_1: + class: 'StructurePruner' + pruning_axis: + '*': 0 + criterions: + '*': 'l1_norm' +controllers: + sa_controller: + class: 'SAController' + reduce_rate: 0.9 + init_temperature: 100 + max_iter_number: 300 +strategies: + auto_pruning_strategy: + class: 'AutoPruneStrategy' + pruner: 'pruner_1' + controller: 'sa_controller' + start_epoch: 0 + end_epoch: 500 + retrain_epoch: 0 + max_ratio: 0.50 + min_ratio: 0.48 + uniform_range: 0.4 + pruned_params: '.*_sep_weights' + metric_name: 'acc_top1' +compressor: + epoch: 500 + checkpoint_path: './checkpoints_auto_pruning/' + strategies: + - auto_pruning_strategy diff --git a/PaddleSlim/run.sh b/PaddleSlim/run.sh index 791b42da..23d7498f 100644 --- a/PaddleSlim/run.sh +++ b/PaddleSlim/run.sh @@ -67,6 +67,14 @@ cd - #--pretrained_model ./pretrain/MobileNetV1_pretrained \ #--compress_config ./configs/filter_pruning_uniform.yaml +# for auto filter pruning +#--------------------------- +#export CUDA_VISIBLE_DEVICES=0 +#python compress.py \ +#--model "MobileNet" \ +#--pretrained_model ./pretrain/MobileNetV1_pretrained \ +#--compress_config ./configs/auto_prune.yaml + # for quantization #----------------- #export CUDA_VISIBLE_DEVICES=0 -- GitLab