Repository: PaddlePaddle/PaddleDetection

Issue:
剪裁问题
想问下，剪裁报错The weights have been pruned once.
这是什么原因，如何解决呢


Discussion:
请问您用的paddle版本，paddledeteciton版本是多少呢？
> 请问您用的paddle版本，paddledeteciton版本是多少呢？

paddle2.0.1，paddledetection2.0rc
@guotongjian 麻烦发一下运行的命令
> @guotongjian 麻烦发一下运行的命令

`python slim/prune/prune.py -c configs/dcn/mymodel.yml  \
--pruned_params "conv1_1_weights,conv1_2_weights,res2a_branch2a_weights,res2a_branch2b_weights,res2b_branch2a_weights,res2b_branch2b_weights,res2c_branch2a_weights,res2c_branch2b_weights,res3a_branch2a_weights,res3a_branch2b_weights,res3b_branch2a_weights,res3b_branch2b_weights,res3c_branch2a_weights,res3c_branch2b_weights,res3d_branch2a_weights,res3d_branch2b_weights,res4a_branch2a_weights,res4a_branch2b_weights,res4b_branch2a_weights,res4b_branch2b_weights,res4c_branch2a_weights,res4c_branch2b_weights,res4d_branch2a_weights,res4d_branch2b_weights,res4e_branch2a_weights,res4e_branch2b_weights,res4f_branch2a_weights,res4f_branch2b_weights,yolo_block.0.0.0.conv.weights,yolo_block.0.0.1.conv.weights,yolo_block.0.1.0.conv.weights,yolo_block.0.1.1.conv.weights,yolo_block.0.2.conv.weights,yolo_block.0.tip.conv.weights,yolo_transition.0.conv.weights,yolo_block.1.0.0.conv.weights,yolo_block.1.0.1.conv.weights,yolo_block.1.1.0.conv.weights,yolo_block.1.1.1.conv.weights,yolo_block.1.2.conv.weights,yolo_block.1.tip.conv.weights,yolo_transition.1.conv.weights,yolo_block.2.0.0.conv.weights,yolo_block.2.0.1.conv.weights,yolo_block.2.1.0.conv.weights,yolo_block.2.2.conv.weights,yolo_block.2.tip.conv.weights  \
--pruned_ratios="0.3,0.3,0.3,0.5,0.6,0.4,0.8,0.8,0.9,0.9,0.7,0.9,0.4,0.5,0.8,0.8,0.9,0.8,0.6,0.5,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.7,0.2,0.5,0.2,0.2,0.3,0.1,0.6,0.1,0.4,0.4,0.5,0.5,0.8,0.7,0.1,0.5,0.4,0.6,0.5" \
 -o weights=output/mymodel/best_model \
--eval \
--prune_criterion=geometry_median`
这是我的命令，请大佬指教
@wanghaoshuang  @qingqing01 my dear大佬，能帮忙看看吗

Resolving patch:
diff --git a/static/slim/prune/prune.py b/static/slim/prune/prune.py
--- a/static/slim/prune/prune.py
+++ b/static/slim/prune/prune.py
@@ -203,21 +203,7 @@ def main():
     assert FLAGS.prune_criterion in ['l1_norm', 'geometry_median'], \
             "unsupported prune criterion {}".format(FLAGS.prune_criterion)
     pruner = Pruner(criterion=FLAGS.prune_criterion)
-    train_prog = pruner.prune(
-        train_prog,
-        fluid.global_scope(),
-        params=pruned_params,
-        ratios=pruned_ratios,
-        place=place,
-        only_graph=False)[0]
-
-    compiled_train_prog = fluid.CompiledProgram(train_prog).with_data_parallel(
-        loss_name=loss.name,
-        build_strategy=build_strategy,
-        exec_strategy=exec_strategy)
-
     if FLAGS.eval:
-
         base_flops = flops(eval_prog)
         eval_prog = pruner.prune(
             eval_prog,
@@ -232,6 +218,19 @@ def main():
             pruned_flops))
         compiled_eval_prog = fluid.CompiledProgram(eval_prog)
 
+    train_prog = pruner.prune(
+        train_prog,
+        fluid.global_scope(),
+        params=pruned_params,
+        ratios=pruned_ratios,
+        place=place,
+        only_graph=False)[0]
+
+    compiled_train_prog = fluid.CompiledProgram(train_prog).with_data_parallel(
+        loss_name=loss.name,
+        build_strategy=build_strategy,
+        exec_strategy=exec_strategy)
+
     if FLAGS.resume_checkpoint:
         checkpoint.load_checkpoint(exe, train_prog, FLAGS.resume_checkpoint)
         start_iter = checkpoint.global_step()


Test patch: