Code for PackNet: Adding Multiple Tasks to a Single Network by Iterative Pruning

Overview

PackNet: https://arxiv.org/abs/1711.05769

Pretrained models are available here: https://uofi.box.com/s/zap2p03tnst9dfisad4u0sfupc0y1fxt
Datasets in PyTorch format are available here: https://uofi.box.com/s/ixncr3d85guosajywhf7yridszzg5zsq
The PyTorch-friendly Places365 dataset can be downloaded from http://places2.csail.mit.edu/download.html
Place models in checkpoints/ and unzipped datasets in data/

VGG-16 LwF VGG-16 VGG-16 BN ResNet-50 DenseNet-121
ImageNet 36.58 (14.75) 29.19 (9.90) 27.10 (8.70) 24.33 (7.17) 25.51 (7.85)
CUBS 34.24 22.56 20.43 19.59 20.11
Stanford Cars 22.07 17.09 14.92 14.03 16.18
Flowers 12.15 11.07 8.59 8.12 9.07

Note that the numbers in the paper are averaged over multiple runs for each ordering of datasets. The pretrained models are for a specific dataset addition ordering: (c) CUBS Birds, (s) Stanford Cars, (f) Flowers.

These numbers were obtained by evaluating the models on a Titan X (Pascal).
Note that numbers on other GPUs might be slightly different (~0.1%) owing to cudnn algorithm selection.
https://discuss.pytorch.org/t/slightly-different-results-on-k-40-v-s-titan-x/10064

Requirements:

Python 2.7 or 3.xx
torch==0.2.0.post3
torchvision==0.1.9
torchnet (pip install git+https://github.com/pytorch/tnt.git@master)
tqdm (pip install tqdm)

Training:

Check out the scripts in src/scripts.
Run all code from the src/ directory, e.g. ./scripts/run_all.sh

Eval:

cd src  # Run everything from src/

# Pruning-based models.
python main.py --mode eval --dataset cubs_cropped \
  --loadname ../checkpoints/csf_0.75,0.75,-1_vgg16_0.5-nobias-nobn_1.pt

# LwF models.
python lwf.py --mode eval --dataset cubs_cropped \
  --loadname ../checkpoints/csf_lwf.pt
Comments
  • AttributeError: 'BatchNorm2d' object has no attribute 'track_running_stats'

    AttributeError: 'BatchNorm2d' object has no attribute 'track_running_stats'

    hello,

    I run this command:

    python main.py --mode eval --dataset cubs_cropped \
      --loadname ../checkpoints/csf_0.75,0.75,-1_vgg16_0.5-nobias-nobn_1.pt
    

    everything is ok, but test other model,

    python main.py --mode eval --dataset cubs_cropped \
      --loadname ../checkpoints/csf_0.75,0.75,-1_vgg16bn_0.5-nobias-nobn_1.pt
    

    or

    python main.py --mode eval --dataset cubs_cropped \
      --loadname ../checkpoints/csf_0.75,0.75,-1_densenet121_0.5-nobias-nobn_1.pt
    

    problem happened.

    result = self.forward(*input, **kwargs)
    File "pytorch_test/ijcai/packnet/src/networks.py", line 78, in forward
         x = self.shared(x)
    File "pytorch_test/env3/lib/python3.5/site-packages/torch/nn/modules/module.py",
        result = self.forward(*input, **kwargs)
    File "/home/linning/pytorch_test/env3/lib/python3.5/site-packages/torch/nn/modules/batchnorm.py", line 49, 
         self.training or not self.track_running_stats, self.momentum, self.eps)
    AttributeError: 'BatchNorm2d' object has no attribute 'track_running_stats'
    

    My PyTorch version is : 0.4.0, python version is 3.5 Could you help me fixed it, thank you! @arunmallya

    opened by MrLinNing 4
  • is there any way to upgrade to newer pytorch version

    is there any way to upgrade to newer pytorch version

    hi @arunmallya ,I try to run script ./scripts/run_lwf.sh csf ../checkpoints/imagenet/vgg16.pt 2,3

    seems vgg16.pt file worked with pytorch 0.2.0.post3, and can download from https://uofi.box.com/s/zap2p03tnst9dfisad4u0sfupc0y1fxt

    is there any way to upgrade to newer pytorch version, such as pytorch 1.6

    Thanks

    opened by pardont 1
  • run is slow and some errors

    run is slow and some errors

    Hello, thank you very much for sharing. But I ran into some problems while running your code. I would really appreciate it if you could help me.

    1. I'm running

    Python main. Py - mode eval - dataset cubs_cropped - loadname/home/qiuyu/packnet - master/checkpoints/csf_0,0.75, 75-1 _vgg16_0. 5 - nobias - nobn_1. Pt

    In this code, the program appeared "killed" and then stopped running. I wonder if it was because of my computer configuration. I used i5 and gpu=2070. When you run this program, the computer gets really stuck.

    1. I'm running @@@@ Bash run_all_baseline_finetuning. Sh

    This code, the program is reporting an error, Traceback (most recent call last): File "main.py", line 393, in The main () File "main.py", line 377, in main The save = True, savename = args. Save_prefix) File "main.py", line 215, in train Self. Do_epoch (epoch_idx, optimizer) File "main.py", line 172, in do_epoch For batch, label in TQDM (self.train_data_loader, desc='Epoch: %d '% (epoch_idx)): The File "/ home/qiuyu/anaconda3 / envs/pytorch/lib/python3.6 / site - packages/TQDM _tqdm. Py", line 1017, in iter For obj in iterable: The File "/ home/qiuyu/anaconda3 / envs/pytorch/lib/python3.6 / site - packages/torch/utils/data/dataloader py", line 301, in iter Return DataLoaderIter (self) The File "/ home/qiuyu/anaconda3 / envs/pytorch/lib/python3.6 / site - packages/torch/utils/data/dataloader py", line 158, in init Baron tart () The File "/ home/qiuyu/anaconda3 / envs/pytorch/lib/python3.6 / multiprocessing/process. Py", line 105, in the start Self. _popen = self. _popen (self) The File "/ home/qiuyu/anaconda3 / envs/pytorch/lib/python3.6 / multiprocessing/context. Py", line 223, in _Popen Return _default_context. Get_context (). The Process. _Popen (process_obj) The File "/ home/qiuyu/anaconda3 / envs/pytorch/lib/python3.6 / multiprocessing/context. Py", line 277, in _Popen Return Popen (process_obj) The File "/ home/qiuyu/anaconda3 / envs/pytorch/lib/python3.6 multiprocessing/popen_fork py", line 19, in init Self. _launch (process_obj) The File "/ home/qiuyu/anaconda3 / envs/pytorch/lib/python3.6 multiprocessing/popen_fork py", line 66, in _launch The self. The pid = OS. The fork () OSError: [Errno 12] no allocate memory

    What's the reason for this? Looking forward to your reply. Thank you very much. @

    opened by Breezeqiuyu 1
  • Time inference is same after pruning model by Pytorch

    Time inference is same after pruning model by Pytorch

    Hello

    Please, I have a problem concerning the optimization of YOLOX model by Pytorch Pruning (Global & Local) I got the same inference time after the optimization, I don't understand why ?

    is it that the prune model by Pytoch does not remove the tensors which have equal to 0 after the equalization or there is another thing

    any help

    thanks in advance

    opened by AouatifZ 0
  • mask update in func 'make_finetuning_mask'

    mask update in func 'make_finetuning_mask'

    I am new in this task and read your code briefly。 Does line 137 in src/prune.py : ' self.current_masks = self.previous_masks' should be 'self.current_masks = mask'?

    opened by chenxi52 0
  • Running 'run_all_baseline_finetuning.sh': KeyError: 'model'

    Running 'run_all_baseline_finetuning.sh': KeyError: 'model'

    Hi @arunmallya :

    Running Platform: GoogleColab Environment: Python3.6 torch==0.2.0.post3 torchvision==0.1.9 torchnet, tqdm I have changed "raw_input()" to "input()" in network.py. When I try to run the program, the following error occurs.

    Traceback (most recent call last): File "main.py", line 393, in main() File "main.py", line 331, in main model = ckpt['model'] KeyError: 'model'

    The file structure below the project is the same as your GitHub commit, where the file structure in checkpoints is shown below. image

    The contents of the imagenet folder are shown below. image

    The files vgg16.pt, vgg16bn.pt, resnet50.pt, densenet121.pt were downloaded in the same environment with the following code. vgg16 = torchvision.models.vgg16(pretrained=True) torch.save(vgg16.state_dict(), "/content/drive/MyDrive/packnet/vgg16.pt"). The other model files are downloaded in the same way.

    How should I fix this error? Is there a mistake in the way I download the model? Or is the problem with the network.py file?

    One more question. Is there a requirement for the order in which the .sh files are run? I am talking about the following .sh files. run_all_baseline_finetuning.sh run_all_lwf.sh run_all_sequence.sh

    Thanks

    opened by L-Daniel-ee 4
Owner
Arun Mallya
NVIDIA Research
Arun Mallya
Code for Piggyback: Adapting a Single Network to Multiple Tasks by Learning to Mask Weights

Piggyback: https://arxiv.org/abs/1801.06519 Pretrained masks and backbones are available here: https://uofi.box.com/s/c5kixsvtrghu9yj51yb1oe853ltdfz4q

Arun Mallya 165 Nov 22, 2022
[CVPR 2021] Official PyTorch Implementation for "Iterative Filter Adaptive Network for Single Image Defocus Deblurring"

IFAN: Iterative Filter Adaptive Network for Single Image Defocus Deblurring Checkout for the demo (GUI/Google Colab)! The GUI version might occasional

Junyong Lee 173 Dec 30, 2022
Code of U2Fusion: a unified unsupervised image fusion network for multiple image fusion tasks, including multi-modal, multi-exposure and multi-focus image fusion.

U2Fusion Code of U2Fusion: a unified unsupervised image fusion network for multiple image fusion tasks, including multi-modal (VIS-IR, medical), multi

Han Xu 129 Dec 11, 2022
Code repo for "RBSRICNN: Raw Burst Super-Resolution through Iterative Convolutional Neural Network" (Machine Learning and the Physical Sciences workshop in NeurIPS 2021).

RBSRICNN: Raw Burst Super-Resolution through Iterative Convolutional Neural Network An official PyTorch implementation of the RBSRICNN network as desc

Rao Muhammad Umer 6 Nov 14, 2022
implementation of paper - You Only Learn One Representation: Unified Network for Multiple Tasks

YOLOR implementation of paper - You Only Learn One Representation: Unified Network for Multiple Tasks To reproduce the results in the paper, please us

Kin-Yiu, Wong 1.8k Jan 4, 2023
RefineGNN - Iterative refinement graph neural network for antibody sequence-structure co-design (RefineGNN)

Iterative refinement graph neural network for antibody sequence-structure co-des

Wengong Jin 83 Dec 31, 2022
A curated list of neural network pruning resources.

A curated list of neural network pruning and related resources. Inspired by awesome-deep-vision, awesome-adversarial-machine-learning, awesome-deep-learning-papers and Awesome-NAS.

Yang He 1.7k Jan 9, 2023
Group Fisher Pruning for Practical Network Compression(ICML2021)

Group Fisher Pruning for Practical Network Compression (ICML2021) By Liyang Liu*, Shilong Zhang*, Zhanghui Kuang, Jing-Hao Xue, Aojun Zhou, Xinjiang W

Shilong Zhang 129 Dec 13, 2022
A Closer Look at Structured Pruning for Neural Network Compression

A Closer Look at Structured Pruning for Neural Network Compression Code used to reproduce experiments in https://arxiv.org/abs/1810.04622. To prune, w

Bayesian and Neural Systems Group 140 Dec 5, 2022
Network Pruning That Matters: A Case Study on Retraining Variants (ICLR 2021)

Network Pruning That Matters: A Case Study on Retraining Variants (ICLR 2021)

Duong H. Le 18 Jun 13, 2022
An implementation of based on pytorch and mmcv

FisherPruning-Pytorch An implementation of <Group Fisher Pruning for Practical Network Compression> based on pytorch and mmcv Main Functions Pruning f

Peng Lu 15 Dec 17, 2022
Ensemble Knowledge Guided Sub-network Search and Fine-tuning for Filter Pruning

Ensemble Knowledge Guided Sub-network Search and Fine-tuning for Filter Pruning This repository is official Tensorflow implementation of paper: Ensemb

Seunghyun Lee 12 Oct 18, 2022
source code the paper Fast and Robust Iterative Closet Point.

Fast-Robust-ICP This repository includes the source code the paper Fast and Robust Iterative Closet Point. Authors: Juyong Zhang, Yuxin Yao, Bailin De

yaoyuxin 320 Dec 28, 2022
Automatically Build Multiple ML Models with a Single Line of Code. Created by Ram Seshadri. Collaborators Welcome. Permission Granted upon Request.

Auto-ViML Automatically Build Variant Interpretable ML models fast! Auto_ViML is pronounced "auto vimal" (autovimal logo created by Sanket Ghanmare) N

AutoViz and Auto_ViML 397 Dec 30, 2022
PyTorch code for 'Efficient Single Image Super-Resolution Using Dual Path Connections with Multiple Scale Learning'

Efficient Single Image Super-Resolution Using Dual Path Connections with Multiple Scale Learning This repository is for EMSRDPN introduced in the foll

null 7 Feb 10, 2022
[CVPR2021] The source code for our paper 《Removing the Background by Adding the Background: Towards Background Robust Self-supervised Video Representation Learning》.

TBE The source code for our paper "Removing the Background by Adding the Background: Towards Background Robust Self-supervised Video Representation Le

Jinpeng Wang 150 Dec 28, 2022
Data & Code for ACCENTOR Adding Chit-Chat to Enhance Task-Oriented Dialogues

ACCENTOR: Adding Chit-Chat to Enhance Task-Oriented Dialogues Overview ACCENTOR consists of the human-annotated chit-chat additions to the 23.8K dialo

Facebook Research 69 Dec 29, 2022
A lightweight Python-based 3D network multi-agent simulator. Uses a cell-based congestion model. Calculates risk, loudness and battery capacities of the agents. Suitable for 3D network optimization tasks.

AMAZ3DSim AMAZ3DSim is a lightweight python-based 3D network multi-agent simulator. It uses a cell-based congestion model. It calculates risk, battery

Daniel Hirsch 13 Nov 4, 2022
Official pytorch code for "APP: Anytime Progressive Pruning"

APP: Anytime Progressive Pruning Diganta Misra1,2,3, Bharat Runwal2,4, Tianlong Chen5, Zhangyang Wang5, Irina Rish1,3 1 Mila - Quebec AI Institute,2 L

Landskape AI 12 Nov 22, 2022