Skip to content

Commit 14b392c

Browse files
author
Lucas Liebenwein
committed
Sparse Flow (Node) paper and v2.2.0 release
1 parent 2e59069 commit 14b392c

File tree

211 files changed

+16859
-3126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

211 files changed

+16859
-3126
lines changed

README.md

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
# Neural Network Pruning
2-
[Lucas Liebenwein](https://people.csail.mit.edu/lucasl/),
3-
[Cenk Baykal](http://www.mit.edu/~baykal/),
4-
[Alaa Maalouf](https://www.linkedin.com/in/alaa-maalouf/),
5-
[Igor Gilitschenski](https://www.gilitschenski.org/igor/),
6-
[Dan Feldman](http://people.csail.mit.edu/dannyf/),
7-
[Daniela Rus](http://danielarus.csail.mit.edu/)
1+
# torchprune
2+
Main contributors of this code base:
3+
[Lucas Liebenwein](http://www.mit.edu/~lucasl/),
4+
[Cenk Baykal](http://www.mit.edu/~baykal/).
5+
6+
Please check individual paper folders for authors of each paper.
87

98
<p align="center">
109
<img src="./misc/imgs/pruning_pipeline.png" width="100%">
@@ -15,10 +14,11 @@ This repository contains code to reproduce the results from the following
1514
papers:
1615
| Paper | Venue | Title & Link |
1716
| :---: | :---: | :--- |
17+
| **Node** | NeurIPS 2021 | [Sparse Flows: Pruning Continuous-depth Models](https://proceedings.neurips.cc/paper/2021/hash/bf1b2f4b901c21a1d8645018ea9aeb05-Abstract.html) |
1818
| **ALDS** | NeurIPS 2021 | [Compressing Neural Networks: Towards Determining the Optimal Layer-wise Decomposition](https://arxiv.org/abs/2107.11442) |
1919
| **Lost** | MLSys 2021 | [Lost in Pruning: The Effects of Pruning Neural Networks beyond Test Accuracy](https://proceedings.mlsys.org/paper/2021/hash/2a79ea27c279e471f4d180b08d62b00a-Abstract.html) |
2020
| **PFP** | ICLR 2020 | [Provable Filter Pruning for Efficient Neural Networks](https://openreview.net/forum?id=BJxkOlSYDH) |
21-
| **SiPP** | arXiv | [SiPPing Neural Networks: Sensitivity-informed Provable Pruning of Neural Networks](https://arxiv.org/abs/1910.05422) |
21+
| **SiPP** | SIAM 2022 | [SiPPing Neural Networks: Sensitivity-informed Provable Pruning of Neural Networks](https://doi.org/10.1137/20M1383239) |
2222

2323
### Packages
2424
In addition, the repo also contains two stand-alone python packages that
@@ -35,6 +35,7 @@ about the paper and scripts and parameter configuration to reproduce the exact
3535
results from the paper.
3636
| Paper | Location |
3737
| :---: | :---: |
38+
| **Node** | [paper/node](./paper/node) |
3839
| **ALDS** | [paper/alds](./paper/alds) |
3940
| **Lost** | [paper/lost](./paper/lost) |
4041
| **PFP** | [paper/pfp](./paper/pfp) |
@@ -98,14 +99,27 @@ using the codebase.
9899
| --- | --- |
99100
| [src/torchprune/README.md](./src/torchprune) | more details to prune neural networks, how to use and setup the data sets, how to implement custom pruning methods, and how to add your data sets and networks. |
100101
| [src/experiment/README.md](./src/experiment) | more details on how to configure and run your own experiments, and more information on how to re-produce the results. |
102+
| [paper/node/README.md](./paper/node) | check out for more information on the [Node](https://proceedings.neurips.cc/paper/2021/hash/bf1b2f4b901c21a1d8645018ea9aeb05-Abstract.html) paper. |
101103
| [paper/alds/README.md](./paper/alds) | check out for more information on the [ALDS](https://arxiv.org/abs/2107.11442) paper. |
102104
| [paper/lost/README.md](./paper/lost) | check out for more information on the [Lost](https://proceedings.mlsys.org/paper/2021/hash/2a79ea27c279e471f4d180b08d62b00a-Abstract.html) paper. |
103105
| [paper/pfp/README.md](./paper/pfp) | check out for more information on the [PFP](https://openreview.net/forum?id=BJxkOlSYDH) paper. |
104-
| [paper/sipp/README.md](./paper/sipp) | check out for more information on the [SiPP](https://arxiv.org/abs/1910.05422) paper. |
106+
| [paper/sipp/README.md](./paper/sipp) | check out for more information on the [SiPP](https://doi.org/10.1137/20M1383239) paper. |
105107

106108
## Citations
107109
Please cite the respective papers when using our work.
108110

111+
### [Sparse flows: Pruning continuous-depth models](https://proceedings.neurips.cc/paper/2021/hash/bf1b2f4b901c21a1d8645018ea9aeb05-Abstract.html)
112+
```
113+
@article{liebenwein2021sparse,
114+
title={Sparse flows: Pruning continuous-depth models},
115+
author={Liebenwein, Lucas and Hasani, Ramin and Amini, Alexander and Rus, Daniela},
116+
journal={Advances in Neural Information Processing Systems},
117+
volume={34},
118+
pages={22628--22642},
119+
year={2021}
120+
}
121+
```
122+
109123
### [Towards Determining the Optimal Layer-wise Decomposition](https://arxiv.org/abs/2107.11442)
110124
```
111125
@inproceedings{liebenwein2021alds,
@@ -140,12 +154,16 @@ url={https://openreview.net/forum?id=BJxkOlSYDH}
140154
}
141155
```
142156

143-
### [SiPPing Neural Networks](https://arxiv.org/abs/1910.05422)
157+
### [SiPPing Neural Networks](https://doi.org/10.1137/20M1383239) (Weight Pruning)
144158
```
145-
@article{baykal2019sipping,
146-
title={SiPPing Neural Networks: Sensitivity-informed Provable Pruning of Neural Networks},
147-
author={Baykal, Cenk and Liebenwein, Lucas and Gilitschenski, Igor and Feldman, Dan and Rus, Daniela},
148-
journal={arXiv preprint arXiv:1910.05422},
149-
year={2019}
159+
@article{baykal2022sensitivity,
160+
title={Sensitivity-informed provable pruning of neural networks},
161+
author={Baykal, Cenk and Liebenwein, Lucas and Gilitschenski, Igor and Feldman, Dan and Rus, Daniela},
162+
journal={SIAM Journal on Mathematics of Data Science},
163+
volume={4},
164+
number={1},
165+
pages={26--45},
166+
year={2022},
167+
publisher={SIAM}
150168
}
151169
```

misc/imgs/node_overview.png

137 KB
Loading

misc/requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
-e ./src/experiment
44

55
# We need those with special tags unfortunately...
6-
-f https://download.pytorch.org/whl/torch_stable.html
7-
torch==1.7.1+cu110
8-
torchvision==0.8.2+cu110
9-
torchaudio===0.7.2
6+
-f https://download.pytorch.org/whl/lts/1.8/torch_lts.html
7+
torch==1.8.2+cu111
8+
torchvision==0.9.2+cu111
9+
torchaudio==0.8.2
1010

1111
# Some extra requirements for the code base
1212
jupyter

paper/alds/script/results_viewer.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
TABLE_BOLD_THRESHOLD = 0.005
3939

4040
# auto-discover files from folder without "common.yaml"
41-
FILES = glob.glob(os.path.join(FOLDER, "[!common]*.yaml"))
41+
FILES = glob.glob(os.path.join(FOLDER, "*[!common]*.yaml"))
4242

4343

4444
def key_files(item):
@@ -52,6 +52,7 @@ def key_files(item):
5252
"resnet18",
5353
"resnet101",
5454
"wide_resnet50_2",
55+
"mobilenet_v2",
5556
"deeplabv3_resnet50",
5657
]
5758

@@ -127,6 +128,8 @@ def get_results(file, logger, legend_on):
127128
elif "imagenet/prune" in file:
128129
graphers[0]._figure.gca().set_xlim([0, 87])
129130
graphers[0]._figure.gca().set_ylim([-87, 5])
131+
elif "imagenet/retrain/mobilenet_v2" in file:
132+
graphers[0]._figure.gca().set_ylim([-5, 0.5])
130133
elif "imagenet/retrain/" in file:
131134
graphers[0]._figure.gca().set_ylim([-3.5, 1.5])
132135
elif "imagenet/retraincascade" in file:
@@ -317,6 +320,7 @@ def generate_table_entries(
317320
"resnet18": "ResNet18",
318321
"resnet101": "ResNet101",
319322
"wide_resnet50_2": "WRN50-2",
323+
"mobilenet_v2": "MobileNetV2",
320324
"deeplabv3_resnet50": "DeeplabV3-ResNet50",
321325
}
322326

paper/node/README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Sparse flows: Pruning continuous-depth models
2+
[Lucas Liebenwein*](https://people.csail.mit.edu/lucasl/),
3+
[Ramin Hasani*](http://www.raminhasani.com),
4+
[Alexander Amini](https://www.mit.edu/~amini/),
5+
[Daniela Rus](http://danielarus.csail.mit.edu/)
6+
7+
***Equal contribution**
8+
9+
<p align="center">
10+
<img align="center" src="../../misc/imgs/node_overview.png" width="80%">
11+
</p>
12+
<!-- <br clear="left"/> -->
13+
14+
Continuous deep learning architectures enable learning of flexible
15+
probabilistic models for predictive modeling as neural ordinary differential
16+
equations (ODEs), and for generative modeling as continuous normalizing flows.
17+
In this work, we design a framework to decipher the internal dynamics of these
18+
continuous depth models by pruning their network architectures. Our empirical
19+
results suggest that pruning improves generalization for neural ODEs in
20+
generative modeling. We empirically show that the improvement is because
21+
pruning helps avoid mode- collapse and flatten the loss surface. Moreover,
22+
pruning finds efficient neural ODE representations with up to 98% less
23+
parameters compared to the original network, without loss of accuracy. We hope
24+
our results will invigorate further research into the performance-size
25+
trade-offs of modern continuous-depth models.
26+
27+
## Setup
28+
Check out the main [README.md](../../README.md) and the respective packages for
29+
more information on the code base.
30+
31+
## Overview
32+
33+
### Run compression experiments
34+
The experiment configurations are located [here](./param). To reproduce the
35+
experiments for a specific configuration, run:
36+
```bash
37+
python -m experiment.main param/toy/ffjord/spirals/vanilla_l4_h64.yaml
38+
```
39+
40+
The pruning experiments will be run fully automatically and store all the
41+
results.
42+
43+
### Experimental evaluations
44+
45+
The [script](./script) contains the evaluation and plotting scripts to
46+
evaluate and analyze the various experiments. Please take a look at each of
47+
them to understand how to load the pruning experiments and how to analyze
48+
the pruning experiments.
49+
50+
Each plot and experiment presented in the paper can be reproduced this way.
51+
52+
## Citation
53+
Please cite the following paper when using our work.
54+
55+
### Paper link
56+
[Sparse flows: Pruning continuous-depth models](https://proceedings.neurips.cc/paper/2021/hash/bf1b2f4b901c21a1d8645018ea9aeb05-Abstract.html)
57+
58+
### Bibtex
59+
```
60+
@article{liebenwein2021sparse,
61+
title={Sparse flows: Pruning continuous-depth models},
62+
author={Liebenwein, Lucas and Hasani, Ramin and Amini, Alexander and Rus, Daniela},
63+
journal={Advances in Neural Information Processing Systems},
64+
volume={34},
65+
pages={22628--22642},
66+
year={2021}
67+
}
68+
```
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
network:
2+
name: "ffjord_multiscale_cifar"
3+
dataset: "CIFAR10"
4+
outputSize: 10
5+
6+
training:
7+
transformsTrain:
8+
- type: RandomHorizontalFlip
9+
kwargs: {}
10+
transformsTest: []
11+
transformsFinal:
12+
- type: Resize
13+
kwargs: { size: 32 }
14+
- type: ToTensor
15+
kwargs: {}
16+
- type: RandomNoise
17+
kwargs: { "normalization": 255.0 }
18+
19+
loss: "NLLBitsLoss"
20+
lossKwargs: {}
21+
22+
metricsTest:
23+
- type: NLLBits
24+
kwargs: {}
25+
- type: Dummy
26+
kwargs: {}
27+
28+
batchSize: 200 # don't change that since it's hard-coded
29+
30+
optimizer: "Adam"
31+
optimizerKwargs:
32+
lr: 1.0e-3
33+
weight_decay: 0.0
34+
35+
numEpochs: 50
36+
earlyStopEpoch: 0
37+
enableAMP: False
38+
39+
lrSchedulers:
40+
- type: MultiStepLR
41+
stepKwargs: { milestones: [45] }
42+
kwargs: { gamma: 0.1 }
43+
44+
file: "paper/node/param/directories.yaml"
45+
46+
retraining:
47+
startEpoch: 0
48+
49+
experiments:
50+
methods:
51+
- "ThresNet"
52+
- "FilterThresNet"
53+
mode: "cascade"
54+
55+
numRepetitions: 1
56+
numNets: 1
57+
58+
plotting:
59+
minVal: 0.02
60+
maxVal: 0.85
61+
62+
spacing:
63+
- type: "geometric"
64+
numIntervals: 12
65+
maxVal: 0.80
66+
minVal: 0.05
67+
68+
retrainIterations: -1
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
network:
2+
name: "ffjord_multiscale_mnist"
3+
dataset: "MNIST"
4+
outputSize: 10
5+
6+
training:
7+
transformsTrain: []
8+
transformsTest: []
9+
transformsFinal:
10+
- type: Resize
11+
kwargs: { size: 28 }
12+
- type: ToTensor
13+
kwargs: {}
14+
- type: RandomNoise
15+
kwargs: { "normalization": 255.0 }
16+
17+
loss: "NLLBitsLoss"
18+
lossKwargs: {}
19+
20+
metricsTest:
21+
- type: NLLBits
22+
kwargs: {}
23+
- type: Dummy
24+
kwargs: {}
25+
26+
batchSize: 200 # don't change that since it's hard-coded
27+
28+
optimizer: "Adam"
29+
optimizerKwargs:
30+
lr: 1.0e-3
31+
weight_decay: 0.0
32+
33+
numEpochs: 50
34+
earlyStopEpoch: 0
35+
enableAMP: False
36+
37+
lrSchedulers:
38+
- type: MultiStepLR
39+
stepKwargs: { milestones: [45] }
40+
kwargs: { gamma: 0.1 }
41+
42+
file: "paper/node/param/directories.yaml"
43+
44+
retraining:
45+
startEpoch: 0
46+
47+
experiments:
48+
methods:
49+
- "ThresNet"
50+
- "FilterThresNet"
51+
mode: "cascade"
52+
53+
numRepetitions: 1
54+
numNets: 1
55+
56+
plotting:
57+
minVal: 0.02
58+
maxVal: 0.85
59+
60+
spacing:
61+
- type: "geometric"
62+
numIntervals: 12
63+
maxVal: 0.80
64+
minVal: 0.05
65+
66+
retrainIterations: -1

paper/node/param/directories.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# relative directories from where main.py was called
2+
directories:
3+
results: "./data/node/results"
4+
trained_networks: null
5+
training_data: "./data/training"
6+
local_data: "./local"

0 commit comments

Comments
 (0)