GithubHelp home page GithubHelp logo

krishnkant-swarnkar / pytorch-pruning Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 136 KB

Implementation of various neural network pruing methods in pytorch.

License: MIT License

Jupyter Notebook 87.65% Python 12.35%
pruning pytorch neural-network-compression mnist cifar-10 resnet lenet lottery-ticket-hypothesis

pytorch-pruning's Introduction

Pytorch-Pruning

This repository contains the implementations of neural network weight pruning methods.

Available Pruning Methods

Pruning has three stages:

  1. Training
  2. Pruning:
    • OneShotPruning
  3. Retraining
    • No Retraining (none)
    • FineTuning (fine-tuning)
    • Learning Rate Rewinding (lr-rewinding)
    • Weight Rewinding (weight-rewinding)

Usage

Install the following python libraries: torch>=1.6.0 torchvision>=0.7.0 numpy tqdm livelossplot Run : $ mkdir saved_models

To get the pruned models you need:

  1. A Model (torch.nn.module)
    • for which forward() takes input as a single variable "batch"
    • which returns loss function (by default) when the forward() is called, and returns the prediction when get_prediction argument is set to true in the forward.
  2. Torch Data Loaders (train_dataloader, val_dataloader)

See the Jupyter Notebooks (.ipynb files) for a better idea about how to do the pruning. This repository contains implementations of the following Models: lenet, resnet20, resnet32, resnet44, resnet56, resnet110, resnet1202 and functions to load data loaders for MNIST, CIFAR-10

Directory Structure

.
|--- models
|    |--- __init__.py
|    |--- lenet.py
|    |--- resnet.py
|--- pruning
|    |--- unstructured
|    |    |--- __init__.py
|    |    |--- one_shot_pruning.py
|    |    |--- iterative_pruning.py
|    |--- structured
|    |    |--- __init__.py
|--- utils
|    |--- __init__.py
|    |--- data_utils.py
|    |--- train_utils.py
|--- Lisence
|--- README.md
|--- LISENCE

Todo

  1. Write code for weight distribution visualizations for each layer.
  2. Write code for iterative pruning.
  3. Write code for ADMM sparsity regularization.

pytorch-pruning's People

Contributors

krishnkant-swarnkar avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.