RL-Pruner: Structured Pruning Using Reinforcement Learning for CNN Compression and Acceleration

Boyao Wang,Volodymyr Kindratenko
2024-11-10
Abstract:Convolutional Neural Networks (CNNs) have demonstrated exceptional performance in recent years. Compressing these models not only reduces storage requirements, making deployment to edge devices feasible, but also accelerates inference, thereby reducing latency and computational costs. Structured pruning, which removes filters at the layer level, directly modifies the model architecture. This approach achieves a more compact architecture while maintaining target accuracy, ensuring that the compressed model retains good compatibility and hardware efficiency. Our method is based on a key observation: filters in different layers of a neural network have varying importance to the model's performance. When the number of filters to prune is fixed, the optimal pruning distribution across different layers is uneven to minimize performance loss. Layers that are more sensitive to pruning should account for a smaller proportion of the pruning distribution. To leverage this insight, we propose RL-Pruner, which uses reinforcement learning to learn the optimal pruning distribution. RL-Pruner can automatically extract dependencies between filters in the input model and perform pruning, without requiring model-specific pruning implementations. We conducted experiments on models such as GoogleNet, ResNet, and MobileNet, comparing our approach to other structured pruning methods to validate its effectiveness. Our code is available at <a class="link-external link-https" href="https://github.com/Beryex/RLPruner-CNN" rel="external noopener nofollow">this https URL</a>.
Computer Vision and Pattern Recognition,Artificial Intelligence
What problem does this paper attempt to address?
### Problems the paper attempts to solve This paper aims to address the challenges in compression and acceleration of convolutional neural networks (CNNs). Specifically, the author proposes a new method named RL - Pruner, which utilizes reinforcement learning (RL) to learn the optimal pruning distribution, thereby achieving structured pruning. Structured pruning directly modifies the model architecture by removing entire filters in the network to achieve model compression and accelerate inference, while maintaining the target accuracy and ensuring that the compressed model has good compatibility and hardware efficiency. ### Background and motivation As CNNs have shown excellent performance in computer vision tasks such as image classification, detection, and segmentation, the number of parameters in these models has also become larger and larger, resulting in significant computational costs and resource consumption. This makes it difficult to deploy these models on edge devices, because edge devices usually have limited computing power and memory. Therefore, effective CNN compression methods are becoming more and more important. These methods aim to reduce the number of parameters and accelerate inference while maintaining the performance of the original model. ### Main contributions 1. **Propose RL - Pruner**: A post - training structured pruning method based on reinforcement learning, which can automatically extract the dependency relationships between different layers in the input model and perform pruning operations without the need for pruning implementations specific to a particular model. 2. **Dynamically adjust the pruning distribution**: Through the reinforcement learning algorithm, RL - Pruner can dynamically adjust the pruning distribution of different layers to minimize performance loss. 3. **Support multiple CNN architectures**: This method supports multiple popular CNN architectures, including residual connections, concatenation connections, and skip connections, enhancing the generality of the method. 4. **Experimental verification**: Through experiments on multiple popular datasets such as CIFAR - 10 and CIFAR - 100, the effectiveness of RL - Pruner has been verified. The experimental results show that RL - Pruner can achieve significant model compression and acceleration while maintaining high accuracy. ### Method overview 1. **Construct a dependency graph**: First, construct a dependency graph between the layers in the model, recording the mapping relationship of channel indices between the layers. 2. **Allocate inter - layer sparsity**: Use Monte Carlo sampling and Q - learning algorithms to generate a new pruning sparsity distribution and update the policy according to the reward function. 3. **Layer pruning**: Select the output channels to be pruned in each layer according to the Taylor criterion to minimize performance degradation. 4. **Knowledge distillation**: After each pruning step, use the knowledge distillation technique for post - training to recover the performance loss caused by pruning. ### Experimental results - **VGG - 19**: On the CIFAR - 100 dataset, RL - Pruner can maintain less than 1% performance degradation at 60% channel sparsity. - **GoogleNet and MobileNetV3 - Large**: At 40% channel sparsity, they also maintain less than 1% performance degradation. - **ResNet - 56**: Since ResNet - 56 has a large number of layers and fewer parameters per layer, its performance drops rapidly during the pruning process. This may be because the number of channels per layer is small, causing the optimal sparsity distribution to be easily rounded to zero. ### Conclusion RL - Pruner successfully achieves efficient compression and acceleration of CNNs while maintaining high performance by using reinforcement learning to dynamically adjust the pruning distribution. This method performs well on multiple CNN architectures and provides strong support for model compression in practical applications.