Passive pruning of filters in a convolutional neural network
Methods and systems for pruning a convolutional neural network (CNN) include calculating a sum of weights for each filter in a layer of the CNN. The filters in the layer are sorted by respective sums of weights. A set of m filters with the smallest sums of weights is filtered to decrease a computational cost of operating the CNN. The pruned CNN is retrained to repair accuracy loss that results from pruning the filters.
1. A method for pruning a convolutional neural network (CNN), comprising:
calculating a sum of kernel weights of each of a plurality of filters in a layer of the CNN;
sorting the plurality of filters in the layer by respective sums of weights;
pruning m filters with the smallest sums of weights to decrease a computational cost of operating the CNN; and
retraining the pruned CNN to repair accuracy loss that results from pruning the m filters by creating a new kernel layer matrix for the layer and copying un-pruned kernel weights to the new kernel matrix.
2. The method of claim 1 , further comprising pruning feature maps corresponding to the m pruned filters.
3. The method of claim 2 , pruning kernels in a subsequent layer that correspond to the pruned feature maps.
4. The method of claim 1 , further comprising iterating the steps of pruning and retraining until a threshold CNN accuracy is reached.
5. The method of claim 1 , further comprising selecting a number of filters m based on a sensitivity of the layer to pruning.
6. The method of claim 5 , wherein a smaller m is selected for layers that have relatively high sensitivities compared to layers that have relatively low sensitivities.
7. The method of claim 5 , wherein sensitivity to pruning is measured as a degree of accuracy change.
8. A method for pruning a convolutional neural network (CNN), comprising:
calculating a sum of kernel weights of each of a plurality of filters in a layer of the CNN;
sorting the plurality of filters in the layer by respective sums of weights;
selecting a number of filters m based on a sensitivity of the layer to pruning, measured as a degree of accuracy change;
pruning m filters with the smallest sums of weights to decrease a computational cost of operating the CNN;
pruning feature maps corresponding to the m pruned filters;
pruning kernels in a subsequent layer that correspond to the pruned feature maps; and
retraining the pruned CNN to repair accuracy loss that results from pruning the m filters by creating a new kernel layer matrix for the layer and copying un-pruned kernel weights to the new kernel matrix.
9. A system for pruning a convolutional neural network (CNN), comprising:
a hardware processor; and
a memory, configured to store computer program code that, when executed by the hardware processor, is configured to execute:
a pruning module configured to calculate a sum of kernel weights of each of a plurality of filters in a layer of the CNN, to sort the plurality of filters in the layer by respective sums of weights, and to prune m filters with the smallest sums of weights to decrease a computational cost of operating the CNN; and
a training module configured to retrain the pruned CNN to repair accuracy loss that results from pruning the m filters by creating a new kernel layer matrix for the layer and copying un-pruned kernel weights to the new kernel matrix.
10. The system of claim 9 , wherein the pruning module is further configured to prune feature maps corresponding to the m pruned filters.
11. The system of claim 10 , wherein the pruning module is further configured to prune kernels in a subsequent layer that correspond to the pruned feature maps.
12. The system of claim 9 , wherein the pruning module and the training module are further configured to iterate the steps of pruning and retraining until a threshold CNN accuracy is reached.
13. The system of claim 9 , wherein the pruning module is further configured to select a number of filters m based on a sensitivity of the layer to pruning.
14. The system of claim 13 , wherein a smaller m is selected for layers that have relatively high sensitivities compared to layers that have relatively low sensitivities.
15. The system of claim 13 , wherein sensitivity to pruning is measured as a degree of accuracy change.