Finetuning the Pruned Model - 1.2 English

Vitis AI Optimizer User Guide (UG1333)

Document ID
UG1333
Release Date
2020-07-07
Version
1.2 English

The performance of the pruned model will have a certain degree of decline and we need to fine-tune it to improve the performance.

Run the following command to start finetuning.

./vai_p_darknet pruner finetune pruning/cfg

Multi-gpu finetuning is generally faster.

./vai_p_darknet pruner finetune pruning/cfg -gpus 0,1,2,3

The command will output basic information at first. Modify the training parameters in “pruning/yolov3-voc-prune.cfg” if necessary.

$./darknet pruner finetune pruning/cfg -gpus 0,1,2,3
GPUs: 0,1,2,3
Workspace exists: pruning
Finetune model  : pruning/yolov3-voc-prune.cfg
Finetune weights: pruning/weights.prune
...

When pruning and fine-tuning are done, one iteration of pruning is completed. In general, to achieve higher pruning rate without significant loss of performance, the model needs several iterations. A typical workflow is as follow:

  1. Setting a small threshold in configuration file.
  2. Start prune the model.
  3. Fine-tuning the pruned model.
  4. Increasing the threshold.
  5. Back to step 2.

After every iteration of pruning, you need to make two changes before you run next iteration. The first one is to increase the threshold in main cfg file. The second one is to change the output file to avoid overwriting the old results.

Here is a sample for main cfg file modification:

[pruning]
workspace=pruning
datacfg=pruning/voc.data
modelcfg=pruning/yolov3-voc.cfg
prunedcfg=pruning/yolov3-voc-prune.cfg
ana_out_file=pruning/ana.out
# change prune_out_weights to avoid overwriting old results
prune_out_weights=pruning/weights.prune.round2
criteria=0
kernel_batch=2
ignore_layer=80,81,92,93,104,105
yolov3=1
# change threshold from 0.005 to 0.01
threshold=0.01

After the modifications, use the new pruning main cfg file to run the prune command again and you can start a new iteration of pruning.