Git Product home page Git Product logo

granet's Introduction

GraNet

Sparse Training via Boosting Pruning Plasticity with Neuroregeneration
Shiwei Liu,Tianlong Chen,Xiaohan Chen,Zahra Atashgahi,Lu Yin,Huanyu Kou,Li Shen,Mykola Pechenizkiy,Zhangyang Wang, Decebal Constantin Mocanu
https://arxiv.org/abs/2106.10404

Abstract: Works on lottery ticket hypothesis (LTH) and single-shot network pruning (SNIP) have raised a lot of attention currently on post-training pruning (iterative magnitude pruning), and before-training pruning (pruning at initialization). The former method suffers from an extremely large computation cost and the latter category of methods usually struggles with insufficient performance. In comparison, during-training pruning, a class of pruning methods that simultaneously enjoys the training/inference efficiency and the comparable performance, temporarily, has been less explored. To better understand during-training pruning, we quantitatively study the effect of pruning throughout training from the perspective of pruning plasticity (the ability of the pruned networks to recover the original performance). Pruning plasticity can help explain several other empirical observations about neural network pruning in literature. We further find that pruning plasticity can be substantially improved by injecting a brain-inspired mechanism called neuroregeneration, i.e., to regenerate the same number of connections as pruned. We design a novel gradual magnitude pruning (GMP) method, named gradual pruning with zero-cost neuroregeneration, GraNet, advancing state of the art. Perhaps most impressively, GraNet for the first time boosts the sparse-to-sparse training performance over various dense-to-sparse methods by a large margin with ResNet-50 on ImageNet without extending the training time.

This code base is created by Shiwei Liu [email protected] during his Ph.D. at Eindhoven University of Technology.

This repository contains implementaions of sparse training methods: GraNet, RigL, In-Time Over-Parameterization, GMP

Requirements

The library requires Python 3.6.7, PyTorch v1.5.1, and CUDA v10.1. Other version of Pytorch should also work.

To use different sparse training methods on CIFAR


Options:
* --sparse - Enable sparse mode (remove this if want to train dense model)
* --method - type of sparse training method. Choose from: GraNet, GraNet_uniform, DST, GMP, GMP_uniform
* --sparse-init - type of sparse initialization. Choose from: ERK, uniform, GMP, prune_uniform, prune_global, prune_and_grow_uniform, prune_and_grow_global, prune_structured, prune_and_grow_structured
* --model (str) - type of networks
* --growth (str) - growth mode. Choose from: random, gradient, momentum
* --prune (str) - removing mode. Choose from: magnitude, SET, threshold
* --redistribution (str) - redistribution mode. Choose from: magnitude, nonzeros, or none. (default none)
* --init-density (float) - initial density of the sparse model. (default 0.50)
* --final-density (float) - target density of the sparse model. (default 0.05)
* --init-prune-epoch (int) - the starting epoch of gradual pruning.
* --final-prune-epoch (int) - the ending epoch of gradual pruning.
* --prune-rate (float) - The pruning rate for Zero-Cost Neuroregeneration.
* --update-frequency (int) - number of training iterations between two steps of zero-cost neuroregeneration.

The sparse operatin is in the sparsetraining/core.py file.

GraNet (s_i = 0) starts from a dense network and prune to a 90% sparse network

cd CIFAR

python main.py --sparse --method GraNet --prune-rate 0.5 --optimizer sgd --sparse-init ERK --init-density 1 --final-density 0.10 --update-frequency 1000 --l2 0.0005 --lr 0.1 --epochs 160 --model ResNet50 --data cifar10

GraNet (s_i = 0.5) starts from a 50% sparse network

cd CIFAR

python main.py --sparse --method GraNet --prune-rate 0.5 --optimizer sgd --sparse-init ERK --init-density 0.50 --final-density 0.10 --update-frequency 1000 --l2 0.0005 --lr 0.1 --epochs 160 --model ResNet50 --data cifar10

RigL (ITOP Version) with 90% sparse network

cd CIFAR

python main.py --sparse --method DST --prune-rate 0.5 --optimizer sgd --sparse-init ERK --init-density 0.10 --final-density 0.10 --update-frequency 1000 --l2 0.0005 --lr 0.1 --epochs 160 --model ResNet50 --data cifar10

GMP

cd CIFAR

python main.py --sparse --method GMP --prune-rate 0.5 --optimizer sgd --sparse-init ERK --init-density 1 --final-density 0.10 --update-frequency 1000 --l2 0.0005 --lr 0.1 --epochs 160 --model ResNet50 --data cifar10

More training scripts of GraNet can be found in the scripts subdirectory

To use different sparse training methods on ImageNet

GraNet

sparse-to-sparse training (s_i=0.5)

cd ImageNet

python $1multiproc.py --nproc_per_node 2 $1main.py --sparse --sparse-init ERK --method GraNet --init-prune-epoch 0 --final-prune-epoch 30 --init-density 0.5 --final-density 0.2 --multiplier 1 --growth gradient --seed 17 --master_port 5555 -j5 -p 500 --arch resnet50 -c fanin --update-frequency 4000 --label-smoothing 0.1 -b 64 --lr 0.1 --warmup 5 --density 0.2 $2 ../../imagenet2012/ --epochs 100

To reproduce results of 250-epoch:

python $1multiproc.py --nproc_per_node 2 $1main.py --sparse --sparse-init ERK --method GraNet --init-prune-epoch 0 --final-prune-epoch 30 --init-density 0.5 --final-density 0.2 --multiplier 2.5 --growth gradient --seed 17 --master_port 5555 -j5 -p 500 --arch resnet50 -c fanin --update-frequency 4000 --label-smoothing 0.1 -b 64 --lr 0.1 --warmup 5 --density 0.2 $2 ../../imagenet2012/ --epochs 100

dense-to-sparse training (s_i=0.0)

cd ImageNet

python $1multiproc.py --nproc_per_node 2 $1main.py --sparse --sparse-init ERK --method GraNet --init-prune-epoch 0 --final-prune-epoch 30 --init-density 0.0 --final-density 0.2 --multiplier 1 --growth gradient --seed 17 --master_port 5555 -j5 -p 500 --arch resnet50 -c fanin --update-frequency 4000 --label-smoothing 0.1 -b 64 --lr 0.1 --warmup 5 --density 0.2 $2 ../../imagenet2012/ --epochs 100

GMP

cd ImageNet

python $1multiproc.py --nproc_per_node 2 $1main.py --sparse --sparse-init ERK --method GMP --init-prune-epoch 0 --final-prune-epoch 30 --init-density 1.0 --final-density 0.2 --multiplier 1 --growth gradient --seed 17 --master_port 5555 -j5 -p 500 --arch resnet50 -c fanin --update-frequency 4000 --label-smoothing 0.1 -b 64 --lr 0.1 --warmup 5 --density 0.2 $2 ../../imagenet2012/ --epochs 100

RigL (ITOP Version)

cd ImageNet

python $1multiproc.py --nproc_per_node 2 $1main.py --sparse --sparse-init ERK --method DST --init-prune-epoch 0 --final-prune-epoch 30 --init-density 0.2 --final-density 0.2 --multiplier 1 --growth gradient --seed 17 --master_port 5555 -j5 -p 500 --arch resnet50 -c fanin --update-frequency 4000 --label-smoothing 0.1 -b 64 --lr 0.1 --warmup 5 --density 0.2 $2 ../../imagenet2012/ --epochs 100

change --final-density to control the target sparsity

Citation

if you find this repo is helpful, please cite

@article{liu2021sparse, 
title={Sparse Training via Boosting Pruning Plasticity with Neuroregeneration}, 
author={Liu, Shiwei and Chen, Tianlong and Chen, Xiaohan and Atashgahi, Zahra and Yin, Lu and Kou, Huanyu and Shen, Li and Pechenizkiy, Mykola and Wang, Zhangyang and Mocanu, Decebal Constantin}, 
journal={Advances in Neural Information Processing Systems},
year={2021.}
}

granet's People

Contributors

shiweiliuiiiiiii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

granet's Issues

How to reproduce the best result of imagenet top1 acc 76.4%

I am trying to reproduce the best result in your paper with 250 epoch on ImageNet.
Below is the experiment that I had trained on ImageNet:

  • --sparse-init ERK --method GraNet --init-prune-epoch 0
    --final-prune-epoch 75 --init-density 0.5
    --final-density 0.1 --multiplier 1
    --growth gradient --seed 17 --master_port 5555
    -j5 -p 500 --arch resnet50 -c fanin
    --update-frequency 4000
    --label-smoothing 0.1 -b 64
    --lr 0.5 --warmup 5 --density 0.1 $2 /ssd1/dataset/imagenet/ --epochs 250
    I set the final prune epoch to 75 which achieve 75.03% on Imagenet

It will be great if you could share the best configuration of the best result.

Thank you !

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.