项目作者: jack-willturner

项目描述 :
Learning both Weights and Connections for Efficient Neural Networks https://arxiv.org/abs/1506.02626
高级语言: Jupyter Notebook
项目地址: git://github.com/jack-willturner/deep-compression.git
创建时间: 2017-11-03T16:42:09Z
项目社区:https://github.com/jack-willturner/deep-compression

开源协议:MIT License

下载


Learning both Weights and Connections for Efficient Neural Networks

Total alerts
Language grade: Python
GitHub

A PyTorch implementation of this paper.

To run, try:

  1. python train.py --model='resnet34' --checkpoint='resnet34'
  2. python prune.py --model='resnet34' --checkpoint='resnet34'

Usage

The core principle behind the training/pruning/finetuning algorithms is as follows:

  1. from models import get_model
  2. from pruners import get_pruner
  3. model = get_model("resnet18")
  4. pruner = get_pruner("L1Pruner", "unstructured")
  5. for prune_rate in [10, 40, 60, 80]:
  6. pruner.prune(model, prune_rate)

We can choose between structured/unstructured pruning, as well as the pruning methods which are in pruners (at the time of writing we have support only for magnitude-based pruning and Fisher pruning).

Bring your own models

In order to add a new model family to the repository you basically just need to do two things:

  1. Swap out the convolutional layers to use the ConvBNReLU class
  2. Define a get_prunable_layers method which returns all the instances of ConvBNReLU which you want to be prunable

Summary

Given a family of ResNets, we can construct a Pareto frontier of the tradeoff between accuracy and number of parameters:

alt text

Han et al. posit that we can beat this Pareto frontier by leaving network structures fixed, but removing individual parameters:

alt text