From f89fab5b0ada13558b902d30712562f97428aeb4 Mon Sep 17 00:00:00 2001 From: whs Date: Mon, 22 Apr 2019 15:52:24 +0800 Subject: [PATCH] Fix distillation in slim demo. (#2107) --- .../mobilenetv1_resnet50_distillation.yaml | 2 +- PaddleSlim/configs/quantization_dist.yaml | 2 +- PaddleSlim/run.sh | 38 +++++++++++-------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/PaddleSlim/configs/mobilenetv1_resnet50_distillation.yaml b/PaddleSlim/configs/mobilenetv1_resnet50_distillation.yaml index c825edf5..43a8db34 100644 --- a/PaddleSlim/configs/mobilenetv1_resnet50_distillation.yaml +++ b/PaddleSlim/configs/mobilenetv1_resnet50_distillation.yaml @@ -7,7 +7,7 @@ distillers: distillation_loss_weight: 1 l2_distiller: class: 'L2Distiller' - teacher_feature_map: 'fc_1.tmp_0' + teacher_feature_map: 'res_fc.tmp_0' student_feature_map: 'fc_0.tmp_0' distillation_loss_weight: 1 strategies: diff --git a/PaddleSlim/configs/quantization_dist.yaml b/PaddleSlim/configs/quantization_dist.yaml index c178bb26..6f7e6afd 100644 --- a/PaddleSlim/configs/quantization_dist.yaml +++ b/PaddleSlim/configs/quantization_dist.yaml @@ -9,7 +9,7 @@ distillers: distillation_loss_weight: 1 l2_distiller: class: 'L2Distiller' - teacher_feature_map: 'fc_1.tmp_0' + teacher_feature_map: 'res_fc.tmp_0' student_feature_map: 'fc_0.tmp_0' distillation_loss_weight: 1 strategies: diff --git a/PaddleSlim/run.sh b/PaddleSlim/run.sh index 0d370e98..14b2b14a 100644 --- a/PaddleSlim/run.sh +++ b/PaddleSlim/run.sh @@ -34,18 +34,22 @@ export CUDA_VISIBLE_DEVICES=0,1,2,3 # Fixing name conflicts in distillation -mv ResNet50_pretrained/conv1_weights ResNet50_pretrained/res_conv1_weights -mv ResNet50_pretrained/fc_0.w_0 ResNet50_pretrained/res_fc.w_0 -mv ResNet50_pretrained/fc_0.b_0 ResNet50_pretrained/res_fc.b_0 +cd ${pretrain_dir}/ResNet50_pretrained +mv conv1_weights res_conv1_weights +mv fc_0.w_0 res_fc.w_0 +mv fc_0.b_0 res_fc.b_0 +cd - python compress.py \ --model "MobileNet" \ --teacher_model "ResNet50" \ --teacher_pretrained_model ./pretrain/ResNet50_pretrained \ --compress_config ./configs/mobilenetv1_resnet50_distillation.yaml -mv ResNet50_pretrained/res_conv1_weights ResNet50_pretrained/conv1_weights -mv ResNet50_pretrained/res_fc.w_0 ResNet50_pretrained/fc_0.w_0 -mv ResNet50_pretrained/res_fc.b_0 ResNet50_pretrained/fc_0.b_0 +cd ${pretrain_dir}/ResNet50_pretrained +mv res_conv1_weights conv1_weights +mv res_fc.w_0 fc_0.w_0 +mv res_fc.b_0 fc_0.b_0 +cd - # for sensitivity filter pruning #------------------------------- @@ -74,28 +78,32 @@ mv ResNet50_pretrained/res_fc.b_0 ResNet50_pretrained/fc_0.b_0 # for distillation with quantization #----------------------------------- -#export CUDA_VISIBLE_DEVICES=0 +#export CUDA_VISIBLE_DEVICES=4,5,6,7 # ## Fixing name conflicts in distillation -#mv ResNet50_pretrained/conv1_weights ResNet50_pretrained/res_conv1_weights -#mv ResNet50_pretrained/fc_0.w_0 ResNet50_pretrained/res_fc.w_0 -#mv ResNet50_pretrained/fc_0.b_0 ResNet50_pretrained/res_fc.b_0 +#cd ${pretrain_dir}/ResNet50_pretrained +#mv conv1_weights res_conv1_weights +#mv fc_0.w_0 res_fc.w_0 +#mv fc_0.b_0 res_fc.b_0 +#cd - # #python compress.py \ #--model "MobileNet" \ #--teacher_model "ResNet50" \ -#--teacher_pretrained_model ./data/pretrain/ResNet50_pretrained \ +#--teacher_pretrained_model ./pretrain/ResNet50_pretrained \ #--compress_config ./configs/quantization_dist.yaml # -#mv ResNet50_pretrained/res_conv1_weights ResNet50_pretrained/conv1_weights -#mv ResNet50_pretrained/res_fc.w_0 ResNet50_pretrained/fc_0.w_0 -#mv ResNet50_pretrained/res_fc.b_0 ResNet50_pretrained/fc_0.b_0 +#cd ${pretrain_dir}/ResNet50_pretrained +#mv res_conv1_weights conv1_weights +#mv res_fc.w_0 fc_0.w_0 +#mv res_fc.b_0 fc_0.b_0 +#cd - # for uniform filter pruning with quantization #--------------------------------------------- #export CUDA_VISIBLE_DEVICES=0 #python compress.py \ #--model "MobileNet" \ -#--pretrained_model ./data/pretrain/MobileNetV1_pretrained \ +#--pretrained_model ./pretrain/MobileNetV1_pretrained \ #--compress_config ./configs/quantization_pruning.yaml -- GitLab