Home

Awesome

DepthShrinker: A New Compression Paradigm Towards Boosting Real-Hardware Efficiency of Compact Neural Networks

Yonggan Fu, Haichuan Yang, Jiayi Yuan, Meng Li, Cheng Wan, Raghuraman Krishnamoorthi, Vikas Chandra, Yingyan Lin

Accepted at ICML 2022 [Paper Link].

DepthShrinker: Overview

<p align="center"> <img src="images/overview.gif" width="800"> </p>

DepthShrinker: Framework

<p align="center"> <img src="images/framework.png" width="800"> </p>

DepthShrinker: Experimental Results

<p align="center"> <img src="images/results.png" width="800"> </p>

Code Usage

Configurations for training/evaluation are set in config/{config-file}.yaml and some arguments can also be overrided via argparse in the main.py. For example, DS.SEARCH in the config file serves as a flag to switch between the two stages of identifying redundant activation functions and finetuning the network after the removel.

Evaluate Pretrained Models of DepthShrinker

python main.py --cfg configs/{config-file}.yaml \
        --data_path {path-to-imagenet} \
        --batch-size 128 \
        --pretrain {path-to-pretrained-ckpt} \
        --eval \
        --dp 
python main.py --cfg configs/{config-file}.yaml \
        --data_path {path-to-imagenet} \
        --batch-size 128 \
        --pretrain {path-to-pretrained-ckpt} \
        --throughput \
        --dp 

Our pretrained models (at the last epoch) on MobileNetV2-1.4 are available here.

Train with DepthShrinker from Scratch

python main.py --cfg configs/{config-file}.yaml \
        --data_path {path-to-imagenet} \
        --batch-size 256

Citation

@article{fu2022depthshrinker,
  title={DepthShrinker: A New Compression Paradigm Towards Boosting Real-Hardware Efficiency of Compact Neural Networks},
  author={Fu, Yonggan and Yang, Haichuan and Yuan, Jiayi and Li, Meng and Wan, Cheng and Krishnamoorthi, Raghuraman and Chandra, Vikas and Lin, Yingyan},
  journal={arXiv preprint arXiv:2206.00843},
  year={2022}
}

License

The majority of DepthShrinker is licensed under CC-BY-NC, however portions of the project are available under separate license terms: pytorch-image-models (Timm) is licensed under the Apache 2.0 license; Swin-Transformer is licensed under the MIT license.

Contributing

We actively welcome your pull requests! Please see CONTRIBUTING and CODE_OF_CONDUCT for more info.