Home

Awesome

<p align="center" width="100%"> <img src="assets\ring.png" width="20%" height="20%"> </p> <div align="center"> <em> "One model to compress them all, one approach to refine efficiency,<br> One method to decompose tensors and enhance neural proficiency.<br> In the realm of filters, CORING stands tall and true,<br> Preserving dimensions, accuracy it will accrue.<br> Experiments demonstrate its prowess, architectures put to test,<br> FLOPS and parameters reduced, accuracy manifest.<br> Like ResNet-50 in ImageNet's vast domain,<br> Memory and computation requirements it does restrain.<br> Efficiency elevated, generalization takes its flight,<br> In the world of neural networks, C💍RING shines its light." </em> </div>

Visitors License

:ring: Efficient tensor decomposition-based filter pruning

<div> <div align="center"> <a href='https://github.com/pvti' target='_blank'>Van Tien PHAM<sup>1,&#x2709</sup></a>&emsp; <a href='https://yzniyed.blogspot.com/p/about-me.html' target='_blank'>Yassine ZNIYED<sup>1</sup></a>&emsp; <a href='http://tpnguyen.univ-tln.fr/' target='_blank'>Thanh Phuong NGUYEN<sup>1</sup></a>&emsp; </div> <div> <div align="center"> <sup>1</sup><em>Université de Toulon, Aix Marseille Université, CNRS, LIS, UMR 7020, France</em>&emsp; <sup>&#x2709</sup><em>Corresponding Author</em> </div> <div style="text-align: justify"> We present a novel filter pruning method for neural networks, named CORING, for effiCient tensOr decomposition-based filteR prunING. The proposed approach preserves the multidimensional nature of filters by employing tensor decomposition. Our approach leads to a more efficient and accurate way to measure the similarity, compared to traditional methods that use vectorized or matricized versions of filters. This results in more efficient filter pruning without losing valuable information. Experiments conducted on various architectures proved its effectiveness. Particularly, the numerical results show that CORING outperforms state-of-the-art methods in terms of FLOPS and parameters reduction, and validation accuracy. Moreover, CORING demonstrates its ability to increase model generalization by boosting accuracy on several experiments. For example, with VGG-16, we achieve a 58.1% FLOPS reduction by removing 81.6% of the parameters, while increasing the accuracy by 0.46% on CIFAR-10. Even on the large scale ImageNet, for ResNet-50, the top-1 accuracy increased by 0.63%, while reducing 40.8% and 44.8% of memory and computation requirements, respectively. </div> <div> <img class="image" src="assets\Framework.png" width="100%" height="100%"> </div> <div align="center "> The CORING approach for filter pruning in one layer. </div>

:star2: News

Project is under development :construction_worker:. Please stay tuned for more :fire: updates.

:dart: Main results

<div align="center "> <img class="image" src="assets\Performance.png" width="40%" height="100%"> </div> <div align="center "> Comparison of pruning methods for VGG-16 on CIFAR-10. </div> <div style="text-align: justify"> CORING is evaluated on various benchmark datasets with well-known and representative architectures including the classic plain structure VGG-16-BN, the GoogLeNet with inception modules, the ResNet-56 with residual blocks, the DenseNet-40 with dense blocks and the MobileNetV2 with inverted residuals and linear bottlenecks. Due to a large number of simulations, these models are all considered on CIFAR-10. Also, to validate the scalability of CORING, we conduct experiments on the challenging ImageNet dataset with ResNet-50. </div> <details> <summary><strong>1. VGG-16-BN/CIFAR-10</strong></summary> <div align="center">
ModelTop-1 (%)# Params. (↓%)FLOPs (↓%)
VGG-16-BN93.9614.98M(00.0)313.73M(00.0)
L193.405.40M(64.0)206.00M(34.3)
SSS93.023.93M(73.8)183.13M(41.6)
GAL-0.0592.033.36M(77.6)189.49M(39.6)
VAS93.183.92M(73.3)190.00M(39.1)
CHIP93.862.76M(81.6)131.17M(58.1)
EZCrop93.012.76M(81.6)131.17M(58.1)
DECORE-50094.025.54M(63.0)203.08M(35.3)
FPAC94.032.76M(81.6)131.17M(58.1)
CORING-C-5 (Ours)94.422.76M(81.6)131.17M(58.1)
GAL-0.190.732.67M(82.2)171.89M(45.2)
HRank-292.342.64M(82.1)108.61M(65.3)
HRank-193.432.51M(82.9)145.61M(53.5)
DECORE-20093.561.66M(89.0)110.51M(64.8)
EZCrop93.702.50M(83.3)104.78M(66.6)
CHIP93.722.50M(83.3)104.78M(66.6)
FSM93.73N/A(86.3)N/A(66.0)
FPAC93.862.50M(83.3)104.78M(66.6)
AutoBot94.016.44M(57.0)108.71M(65.3)
CORING-C-15 (Ours)94.202.50M(83.3)104.78M(66.6)
HRank-391.231.78M(92.0)73.70M(76.5)
DECORE-5091.680.26M(98.3)36.85M(88.3)
QSFM92.173.68M(75.0)79.00M(74.8)
DECORE-10092.440.51M(96.6)51.20M(81.5)
FSM92.86N/A(90.6)N/A(81.0)
CHIP93.181.90M(87.3)66.95M(78.6)
CORING-C-10 (Ours)93.831.90M(87.3)66.95M(78.6)
</div> </details> <details> <summary><strong>2. ResNet-56/CIFAR-10</strong></summary> <div align="center">
ModelTop-1(%)# Params. (↓%)FLOPs (↓%)
ResNet-5693.260.85M(00.0)125.49M(00.0)
L193.060.73M(14.1)90.90M(27.6)
NISP93.010.49M(42.4)81.00M(35.5)
GAL-0.692.980.75M(11.8)78.30M(37.6)
HRank-193.520.71M(16.8)88.72M(29.3)
DECORE-45093.340.64M(24.2)92.48M(26.3)
TPP93.81N/AN/A(31.1)
CORING-E-5 (Ours)94.760.66M(22.4)91.23M(27.3)
HRank-293.170.49M(42.4)62.72M(50.0)
DECORE-20093.260.43M(49.0)62.93M(49.9)
TPP93.46N/AN/A(49.8)
FSM93.63N/A(43.6)N/A(51.2)
CC-0.593.640.44M(48.2)60M(52.0)
FPAC93.710.48M(42.8)65.94M(47.4)
ResRep93.71N/A59.3M(52.7)
DCP93.72N/A(49.7)N/A(54.8)
EZCrop93.800.48M(42.8)65.94M(47.4)
CHIP94.160.48M(42.8)65.94M(47.4)
CORING-V-5 (Ours)94.220.48M(42.8)65.94M(47.4)
GAL-0.890.360.29M(65.9)49.99M(60.2)
HRank-390.720.27M(68.1)32.52M(74.1)
DECORE-5590.850.13M(85.3)23.22M(81.5)
QSFM91.880.25M(71.3)50.62M(60.0)
CHIP92.050.24M(71.8)34.79M(72.3)
TPP92.35N/AN/A(70.6)
FPAC92.370.24M(71.8)34.79M(72.3)
CORING-E (Ours)92.840.24M(71.8)34.79M(72.3)
</div> </details> <details> <summary><strong>3. DenseNet-40/CIFAR-10</strong></summary> <div align="center">
ModelTop-1 (%)# Params. (↓%)FLOPs (↓%)
DenseNet-4094.811.04M(00.0)282.92M(00.0)
DECORE-17594.850.83M(20.7)228.96M(19.1)
CORING-C (Ours)94.880.80M(23.1)224.12M(20.8)
GAL-0.0194.290.67M(35.6)182.92M(35.3)
HRank-194.240.66M(36.5)167.41M(40.8)
FPAC94.510.62M(40.1)173.39M(38.5)
DECORE-11594.590.56M(46.0)171.36M(39.4)
CORING-E (Ours)94.710.62M(40.4)173.39M(38.8)
FPAC93.660.39M(61.9)113.08M(59.9)
HRank-293.680.48M(53.8)110.15M(61.0)
EZCrop93.760.39M(61.9)113.08M(59.9)
DECORE-7094.040.37M(65.0)128.13M(54.7)
CORING-C (Ours)94.200.45M(56.7)133.17M(52.9)
</div> </details> <details> <summary><strong>4. GoogLeNet-40/CIFAR-10</strong></summary> <div align="center">
ModelTop-1 (%)# Params. (↓%)FLOPs (↓%)
GoogLeNet95.056.15M(00.0)1.52B(00.0)
DECORE-50095.204.73M(23.0)1.22B(19.8)
CORING-V (Ours)95.304.72M(23.3)1.21B(20.4)
L194.543.51M(42.9)1.02B(32.9)
GAL-0.0593.933.12M(49.3)0.94B(38.2)
HRank-194.532.74M(55.4)0.69M(54.9)
FPAC95.042.85M(53.5)0.65B(57.2)
CC-0.595.182.83M(54.0)0.76B(50.0)
CORING-E (Ours)95.322.85M(53.5)0.65B(57.2)
HRank-294.071.86M(69.8)0.45B(70.4)
FSM94.29N/A(64.6)N/A(75.4)
DECORE-17594.330.86M(86.1)0.23B(84.7)
FPAC94.422.09M(65.8)0.40B(73.9)
DECORE-20094.511.17M(80.9)0.33B(78.5)
CLR-RNF-0.9194.852.18M(64.7)0.49B(67.9)
CC-0.694.882.26M(63.3)0.61B(59.9)
CORING-E (Ours)95.032.10M(65.9)0.39B(74.3)
</div> </details> <details> <summary><strong>5. MobileNetv2/CIFAR-10</strong></summary> <div align="center">
ModelTop-1 (%)# Params (↓%)FLOPs (↓%)
MobileNetv294.432.24M(0.0)94.54M(0.0)
DCP94.02N/A(23.6)N/A(26.4)
WM94.02N/AN/A(27.0)
QSFM-PSNR92.061.67M(25.4)57.27M(39.4)
DMC94.49N/AN/A(40.0)
SCOP94.24N/A(36.1)N/A(40.3)
GFBS94.25N/AN/A(42.0)
CORING-V (Ours)94.811.26M(43.8)55.16M(42.0)
CORING-V (Ours)94.440.77M(65.6)38.00M(60.0)
</div> </details> <details> <summary><strong>6. Resnet-50/Imagenet</strong></summary> <div align="center">
ModelTop-1 (%)Top-5 (%)# Params (↓%)FLOPs (↓%)
ResNet-5076.1592.8725.50M(0.0)4.09B(0.0)
AutoPruner-0.374.7692.15N/A3.76B(8.1)
ABCPruner-100%72.8492.9718.02M(29.3)2.56B(37.4)
CLR-RNF-0.274.8592.3116.92M(33.6)2.45B(40.1)
APRS75.58N/A16.17M(35.4)2.29B(44.0)
PFP75.9192.8120.88M(18.1)3.65B(10.8)
LeGR76.2093.00N/AN/A(27.0)
DECORE-876.3193.0222.69M(11.0)3.54B(13.4)
CHIP76.3093.0215.10M(40.8)2.26B(44.8)
TPP76.44N/AN/AN/A(32.9)
CORING-V (Ours)76.7893.2315.10M(40.8)2.26B(44.8)
GAL-0.571.9590.9421.20M(16.9)2.33B(43.0)
AutoPruner-0.573.0591.25N/A2.64B(35.5)
HRank-174.9892.3316.15M(36.7)2.30B(43.8)
DECORE-674.5892.1814.10M(44.7)2.36B(42.3)
PFP75.2192.4317.82M(30.1)2.29B(44.0)
FPAC75.6292.6315.09M(40.9)2.26B(45.0)
EZCrop75.6892.7015.09M(40.9)2.26B(45.0)
LeGR75.7092.70N/AN/A(42.0)
SCOP75.9592.7914.59M(42.8)2.24B(45.3)
CHIP76.1592.9114.23M(44.2)2.10B(48.7)
CORING-C (Ours)76.3493.0614.23M(44.2)2.10B(48.7)
GAL-0.5-joint71.8089.1219.31M(24.3)1.84B(55.0)
HRank-271.9891.0113.77M(46.0)1.55B(62.1)
MFMI72.0290.6911.41M(55.2)1.84B(55.0)
FPAC74.1791.8411.05M(56.7)1.52B(62.8)
EZCrop74.3392.0011.05M(56.7)1.52B(62.8)
CC-0.674.5492.2510.58M(58.5)1.53B(62.6)
APRS74.72N/AN/AN/A(57.2)
TPP75.12N/AN/AN/A(60.9)
SCOP75.2692.5312.29M(51.8)1.86B(54.6)
CHIP75.2692.5311.04M(56.7)1.52B(62.8)
LeGR75.3092.40N/AN/A(53.0)
ResRep75.3092.47N/A1.52B(62.1)
CORING-V (Ours)75.5592.6111.04M(56.7)1.52B(62.8)
GAL-1-joint69.3189.1210.21M(60.0)1.11B(72.9)
HRank-369.1089.588.27M(67.6)0.98B(76.0)
DECORE-469.7189.376.12M(76.0)1.19B(70.9)
MFMI69.9189.468.51M(66.6)1.41B(34.4)
DECORE-572.0690.828.87M(65.2)1.60B(60.9)
FPAC72.3090.748.02M(68.6)0.95B(76.7)
ABCPruner-50%72.5890.919.10M(64.3)1.30B(68.2)
CHIP72.3090.748.01M(68.6)0.95B(76.7)
CLR-RNF-0.4472.6791.099.00M(64.7)1.23B(69.9)
CURL73.3991.466.67M(73.8)1.11B(72.9)
CORING-V (Ours)73.9991.718.01M(68.6)0.95B(76.7)
</div> </details>

:wrench: Installation

pip install torch tensorly numpy thop ptflops

:unlock: Verification of our results

Please download the checkpoints and evaluate their performance with the corresponding script and dataset.

:octocat: Reproducibility and further development

  1. To reproduce results, you may run prepared scripts.
  1. Our code is pipelined and can be integrated into other works. Just replace the filter ranking computation.
    # replace your rank calculation here
    rank = get_rank(oriweight, args.criterion, args.strategy)
    

:art: Supplementary materials

1. Poster

<div> <img class="image" src="assets\poster.png" width="100%" height="100%"> </div>

2. Architecture constraint

<p align="center" width="100%"> <img src="assets\residual.png" width="60%" height="60%"> </p>

With shortcut connection architecture, the input and output of each residual block are forced identical. In each layer (i.e, same color), filters with the same style (e.g, sketch) are highly similar, and the empty dashed ones are to be pruned. After pruning, the input and output layer (green and red) has the same number of filters.

3. Computational requirement comparison

<p align="center" width="100%"> <img src="assets\time_benchmark.png" width="50%" height="50%"> </p>

Time consumption to calculate the similarity matrix on VGG-16-BN. For tail layers that contain a larger number of filters, the tensor decomposition method is obviously more efficient.

4. Criteria comparison <a name="metrics"></a>

<p align="center" width="100%"> <img src="assets\criteria_comparison.png" width="75%" height="50%"> </p>

The influence of distance metrics on model accuracy for different architectures and datasets.

5. Throughput acceleration <a name="throughput-acceleration"></a>

<table style="width: 100%; border: none; border-collapse: collapse;"> <tr> <td style="width: 50%; padding: 10px; border: none;"> <img src="assets/baseline_fast.gif" alt="Baseline" style="width: 100%;"> </td> <td style="width: 50%; padding: 10px; border: none;"> <img src="assets/pruned_fast.gif" alt="Pruned" style="width: 100%;"> </td> </tr> </table> <table style="width: 100%; border: none; border-collapse: collapse;"> <tr> <td style="width: 50%; padding: 10px; border: none;"> <img src="assets/baseline_mask.gif" alt="Baseline" style="width: 100%;"> </td> <td style="width: 50%; padding: 10px; border: none;"> <img src="assets/pruned_mask.gif" alt="Pruned" style="width: 100%;"> </td> </tr> </table> <table style="width: 100%; border: none; border-collapse: collapse;"> <tr> <td style="width: 50%; padding: 10px; border: none;"> <img src="assets/baseline_keypoint.gif" alt="Baseline" style="width: 100%;"> </td> <td style="width: 50%; padding: 10px; border: none;"> <img src="assets/pruned_keypoint.gif" alt="Pruned" style="width: 100%;"> </td> </tr> </table> <div align="center"> Baseline (<em>left</em>) vs Pruned (<em>right</em>) model inference. </div>

To emphasize the pragmatic benefits of CORING, an experiment was meticulously conducted comparing a baseline model and a compressed model, both tailored for object detection tasks. Specifically employing the FasterRCNN_ResNet50_FPN architecture on a Tesla T4 GPU, the experiment underscores the remarkable performance enhancement achieved by CORING. The accompanying GIFs provide a clear visual representation: the baseline model demonstrates an inference speed of approximately 7 FPS, while the CORING-compressed model exhibits a notable twofold acceleration in throughput. This compelling contrast aptly demonstrates CORING's efficacy and scalability, firmly establishing its aptness for diverse deployment scenarios.

Note: For replication of this experiment, please refer to detection/README.md.

6. Comparative efficacy study <a name="kmeans"></a>

For a detailed evaluation of CORING's performance, including experiments, results, and visualizations, please refer to the efficacy study.

7. $K$-shots analysis <a name="KShots"></a>

<p align="center" width="100%"> <img src="assets\KShots.png" width="100%" height="50%"> </p>

The influence of $K$, the number of shots, on model accuracy for different architectures and datasets.

:bookmark_tabs: Not-To-Do

:email: Contact

We hope that the new perspective of CORING and its template may inspire more developments :rocket: on network compression.

We warmly welcome your participation in our project!

To contact us, never hesitate to contact pvti@gmail.com. <br></br>

:bookmark: Citation

If the code and paper help your research, please kindly cite:

@article{pham2024efficient,
    title={Efficient tensor decomposition-based filter pruning},
    journal={Neural Networks},
    author={Pham, Van Tien and Zniyed, Yassine and Nguyen, Thanh Phuong},
    year={2024},
  }

:thumbsup: Acknowledgement

This work was granted access to the <a href="http://www.idris.fr/eng/jean-zay/jean-zay-presentation-eng.html">HPC resources of IDRIS</a> under the allocation 2023-103147 made by <a href="https://genci.fr/">GENCI</a>.
The work of T.P. Nguyen is partially supported by <a href="https://anr.fr/Projet-ANR-21-ASRO-0003">ANR ASTRID ROV-Chasseur</a>.
Part of this repository is based on HRankPlus.