YOLOv4 Model Pruning - Extreme Prune Ratios and mAP Drop

• Hardware: NVIDIA GeForce RTX 4090
• Network Type: Yolo_v4
• TLT Version: TAO 5.5.0
• Training spec file:
yolo_v4_train_cspdarknet19_kitti_seq.txt (2.6 KB)
yolo_v4_retrain_cspdarknet19_kitti_seq.txt (2.6 KB)

I am using YOLOv4 with my own dataset, and I encountered some issues when pruning my model. Before training, my model’s mAP is around 0.50. However, when I try to prune with different thresholds (the suggested ones and many others), I always get either an extremely low prune ratio (less than 0.008) or an extremely high prune ratio (greater than 0.98).

I am unable to achieve a prune ratio between 10-20%, which is typically recommended. Additionally, even when I retrain with a prune ratio of 1 or 0.008, my mAP drops to 0 after retraining.

Any insights on what might be causing this or how to resolve it? Thanks in advance.

This does not make sense. You can refer to https://docs.nvidia.com/tao/tao-toolkit/text/cv_finetuning/tensorflow_1/object_detection/yolo_v4.html#pruning-the-model to try more arguments for pruning experiments.
BTW, an example is that another use can get 0.57 of pruning ratio.

Thanks, Morganh!

I tried different pruning parameters as you suggested, and I was able to achieve different pruning ratios. However, when I retrained the network, I still got 0 mAP.

I found that changing the model_ema parameter to FALSE solved the issue. Interestingly, there’s no explanation about model_ema in the YOLO documentation, but in the original retrain spec file, it is set to TRUE by default. Setting it to FALSE resolved the problem.

I also have another question: I couldn’t find any documentation stating that the pruning ratio should ideally be between 10-20% as I found here. My understanding is that it should be set based on the specific problem, correct? For example, when I set the ratio to 0.14 and retrained the model, it reached the original accuracy in less than 5 epochs, which I guess it is because it wasn’t pruned enough.

Would love to hear your thoughts on this!

The ideal pruning ratio depends on the specific problem and model architecture. There is not a hard rule. Pruning involves removing less important weights or neurons from a network to reduce its size and computational cost. Retraining after pruning is essential to recover any lost accuracy. If you’re getting 0 mAP after retraining, it could mean the pruning was too aggressive or the retraining process wasn’t effective. Suggest you to prune a bit → retrain → prune a bit → retrain.

The ModelEMA class is used for Exponential Moving Average (EMA) of model weights, which can help stabilize training and improve model performance. However, it seems that setting model_ema to FALSE resolved your issue with pruning and retraining. This might indicate that the EMA mechanism was interfering with your pruning and retraining process, possibly due to how it updates model weights.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.