## 4 Research Methods
### Software Method
#### 4.1.2 Pruning Process  
After the YOLOv3 is trained, we apply the pruning technique to compress the model and thus improve the performance of the network. The core idea of pruning comes from [42]. Specifically, the scaling factor \(\gamma\), i.e., the weights of the layer, of batch normalization (BN) layer is used as the importance factor. A smaller \(\gamma\) means that the corresponding channel is less important. Nowadays, many CNN models have a BN layer after the convolutional layer, and the importance of both the convolutional layer and the BN layer can be determined based on the scaling factors. By performing threshold filtering on the scores, the less important channels are screened out and then removed from the network. As a result, we can reduce the size of the model without affecting the accuracy of the model too much and achieving the effect of compression. In the specific implementation, it can be divided into three steps as follows:Performing sparse training for the YOLOv3 model with darknet framework. Sparse training in this research means applying the L1 regularization on the weights of BN layers, which results in sparsity of the weights. In this research, we first performed the sparse training and then performed pruning (Method A). However, we found that the model accuracy decreased significantly after pruning. Thus, we adjust some parameters and then perform sparse training again as Method B to improve the accuracy. Specifically, we mainly adjust the learning rate by warping up the learning rate in the first few epochs, and decaying the learning rate in an appropriate proportion after the training reached 70% of the total epoch. After the adjustment, the model accuracy of method B improves significantly compared to method A. This indicates that sparse training plays an important role and can directly affect the accuracy of the model after pruning.
2. Pruning the model after sparse training. We first set an expected pruning percentage, i.e., the proportion of channels that are expected to be cut. Then, threshold concerning the scaling factors is determined and the channels with the scaling factor value smaller than the threshold are pruned. In detail, we tried a total of three methods: Prune method, Shortcut method, and Slim method. Prune method is a conservative strategy. There are five groups of 23 shortcut connections in YOLOv3 corresponding to the added operation. To ensure that the two input dimensions of the shortcut are the same after channel pruning, this method does not prune the layers directly connected to the shortcut. As a result, the prune method avoids the dimension processing. The shortcut method prunes the convolutional layers involved in the shortcut. It uses the mask of the first convolutional layer in the shortcut of each group, and a total of five masks to prune shortcut-related convolutional layers of the five groups. Thus, the pruning rate is improved compared with Prune Method. Slim method has the highest channel pruning rate. First, the mask of each convolutional layer is found with a global threshold. In addition, then for each group of shortcuts, the pruned mask of each connected convolutional layer is taken as a merge set and pruned, so that each relevant layer is considered, and the reserved channels of each layer are also limited.
3. Fine-tuning the pruned model. After pruning, the accuracy of the model decreases inevitably. Thus, a fine-tuning operation, which means retraining the pruned model, is required to compensate for the accuracy loss. Similar to the sparse training process, we can also adjust the learning rate in the fine-tuning process to improve the accuracy of the model. After fine-tuning, we obtain a lightweight YOLOv3 model with a high accuracy.