All Projects → alexfjw → prunnable-layers-pytorch

alexfjw / prunnable-layers-pytorch

Licence: GPL-3.0 license
Prunable nn layers for pytorch.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to prunnable-layers-pytorch

torchprune
A research library for pytorch-based neural network pruning, compression, and more.
Stars: ✭ 133 (+182.98%)
Mutual labels:  compression, pruning
SSD-Pruning-and-quantization
Pruning and quantization for SSD. Model compression.
Stars: ✭ 19 (-59.57%)
Mutual labels:  compression, pruning
Dnc Tensorflow
A TensorFlow implementation of DeepMind's Differential Neural Computers (DNC)
Stars: ✭ 587 (+1148.94%)
Mutual labels:  research, implementation
lips
📘 Lisk improvement proposals
Stars: ✭ 61 (+29.79%)
Mutual labels:  research, implementation
Model Compression And Acceleration Progress
Repository to track the progress in model compression and acceleration
Stars: ✭ 63 (+34.04%)
Mutual labels:  compression, pruning
Aimet
AIMET is a library that provides advanced quantization and compression techniques for trained neural network models.
Stars: ✭ 453 (+863.83%)
Mutual labels:  compression, pruning
fasterai1
FasterAI: A repository for making smaller and faster models with the FastAI library.
Stars: ✭ 34 (-27.66%)
Mutual labels:  compression, pruning
Hrank
Pytorch implementation of our CVPR 2020 (Oral) -- HRank: Filter Pruning using High-Rank Feature Map
Stars: ✭ 164 (+248.94%)
Mutual labels:  compression, pruning
Model Optimization
A toolkit to optimize ML models for deployment for Keras and TensorFlow, including quantization and pruning.
Stars: ✭ 992 (+2010.64%)
Mutual labels:  compression, pruning
Pgm Index
🏅State-of-the-art learned data structure that enables fast lookup, predecessor, range searches and updates in arrays of billions of items using orders of magnitude less space than traditional indexes
Stars: ✭ 499 (+961.7%)
Mutual labels:  compression, research
Pygm
🐍 Python library implementing sorted containers with state-of-the-art query performance and compressed memory usage
Stars: ✭ 156 (+231.91%)
Mutual labels:  compression, research
Nncf
PyTorch*-based Neural Network Compression Framework for enhanced OpenVINO™ inference
Stars: ✭ 218 (+363.83%)
Mutual labels:  compression, pruning
optkeras
OptKeras: wrapper around Keras and Optuna for hyperparameter optimization
Stars: ✭ 29 (-38.3%)
Mutual labels:  deep
zig-snappy
Snappy compression for Zig
Stars: ✭ 25 (-46.81%)
Mutual labels:  compression
dedupsqlfs
Deduplicating filesystem via Python3, FUSE and SQLite
Stars: ✭ 24 (-48.94%)
Mutual labels:  compression
senpai
Molecular dynamics simulation software
Stars: ✭ 124 (+163.83%)
Mutual labels:  research
ethsnarks
A toolkit for viable zk-SNARKS on Ethereum, Web, Mobile and Desktop
Stars: ✭ 224 (+376.6%)
Mutual labels:  research
stripnet
STriP Net: Semantic Similarity of Scientific Papers (S3P) Network
Stars: ✭ 82 (+74.47%)
Mutual labels:  research
api-evangelist
The API Evangelist website
Stars: ✭ 73 (+55.32%)
Mutual labels:  research
blz4
Example of LZ4 compression with optimal parsing using BriefLZ algorithms
Stars: ✭ 24 (-48.94%)
Mutual labels:  compression

Prunable neural network layers for Pytorch

The code in this repo has been extracted from my ML udacity capstone project here, where I experimented with CNNs for Japanese OCR.

Prunable versions of common CNN layers can be found in this repo. We use taylor expansion to estimate the importance of feature maps, as described by Molchanov, P. et al[1].
A good summary of this approach can be found here.

Pruning & taylor estimation was written with an OOP approach for readability.

Dependencies

  • Python 3.6.3
  • Pytorch 0.4
  • torchvision (for vgg example)

Description of code

The layers in prunable_nn.py are plug and play. However, they only compute the importance of each feature map. (pruning is a concept linked to models, and not individual layers). Filtering to select the smallest feature map and dropping inputs for layer next to the pruned layer has to be done manually.

PConv2d is a Conv2d layer which registers a backward hook during gradient calulation to weigh the importance of each feature map.

Feature maps are stored after every forward call, and talyor estimates for feature map importance is calculated after every backward call.

As mentioned, removing a feature map reduces the outputs of the layer. The next immediate layer has to take in fewer inputs. PLinear and PBatchNorm have been written to perform this.

Usage Examples

Simply use PLinear(..), PConv2(..) & PBatchNorm(...) in place of the originals.
Also modify your models to add a prune method.
See models.py for further information.

The tests in ./tests/ may be useful for testing your prunable models.

For benchmarks & examples of the full training & pruning procedure, refer to my ML udacity capstone project here.

Possible Extensions

Making PLinear prunable - shouldn't be too difficult, implementation should be identical to PConv2d.

References

[1] Molchanov, P., Tyree, S., Karras, T., Aila, T., & Kautz, J. (2017, June 08). Pruning Convolutional Neural Networks for Resource Efficient Inference. Retrieved December 10, 2017, from https://arxiv.org/abs/1611.06440

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].