- Requirements
- [Quick start](#Quick start)
- Architecture
- Trainer
- Methodology
- [Layer variants](#Layer variants)
- Network
- [Config and Args](#Config and Args)
- [Added pruning methods](#Added pruning methods)
- [Norm based non-structural method](#Norm based non-structural method)
- [Norm-based filter pruning](#Norm-based filter pruning)
- [Geomeric median-based filter pruning](#Geomeric median-based filter pruning)
- [Create a new pruning methods](#Create a new pruning methods)
- Notes
- Citation
- Python 3.6
- PyTorch 1.0.1 tested, 0.4.0 and above should also work.
- TorchVision 0.2.2
-source source.sh to activate the env. update env name to your existing or create it. -python run1.py
training related class and methods are defined in train3.py, inlcuding train(), validate(), try_resume().
Pruning methods are defined in functions/, for example, mask.py is the method for norm and geo-median filter pruning.
Here new layers is derived from basic Pytorch layers such as Conv2D and Linear. Override the original forward and backward function as needed. In this way, there is no need to explicitly load and rewrite data using buffer at the top main().
Networks are defined in models/, import desired layer variants before constructing the network.
Configurations are fined in config_.py with easydict, which can be updated by arguments. Args parser is in top main file: run1.py.
Here I added several popular pruning methods.
We use the torchvision of 0.3.0. If the version of your torchvision is 0.2.0, then the transforms.RandomResizedCrop
should be transforms.RandomSizedCrop
and the transforms.Resize
should be transforms.Scale
.
This can improve the accuracy slightly.
We follow the Facebook process of ImageNet. Two subfolders ("train" and "val") are included in the "/path/to/ImageNet2012". The correspding code is here.
Refer to the file.
For Filter Pruning via Geometric Median:
@inproceedings{he2019filter,
title = {Filter Pruning via Geometric Median for Deep Convolutional Neural Networks Acceleration},
author = {He, Yang and Liu, Ping and Wang, Ziwei and Hu, Zhilan and Yang, Yi},
booktitle = {Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
year = {2019}
}