Finetuning the Pruned Model - 1.4 English

Vitis AI Optimizer User Guide (UG1333)

Document ID
UG1333
Release Date
2021-07-22
Version
1.4 English

The performance of the pruned model has a certain degree of decline and must be finetuned 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 outputs the 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 follows:

  1. Setting a small threshold in the configuration file.
  2. Start the pruning of 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 the main cfg file and the second one is to change the output file to avoid overwriting the old results.

Here is a sample for the 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.