Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Fix pruner issues #2265

Merged
merged 3 commits into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/model_compress/model_prune_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
'model_name': 'naive',
'pruner_class': AGP_Pruner,
'config_list': [{
'initial_sparsity': 0,
'initial_sparsity': 0.,
'final_sparsity': 0.8,
'start_epoch': 0,
'end_epoch': 10,
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/pynni/nni/compression/torch/pruners.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def update_epoch(self, epoch):
if epoch > 0:
self.now_epoch = epoch
for wrapper in self.get_modules_wrapper():
wrapper.if_calculated.copy_(torch.tensor(0)) # pylint: disable=not-callable
wrapper.if_calculated = False

class SlimPruner(Pruner):
"""
Expand Down
9 changes: 9 additions & 0 deletions test/scripts/model_compression.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ do
python3 model_prune_torch.py --pruner_name $name --pretrain_epochs 1 --prune_epochs 1
done

echo 'testing level pruner pruning'
python3 model_prune_torch.py --pruner_name level --pretrain_epochs 1 --prune_epochs 1

echo 'testing agp pruning'
python3 model_prune_torch.py --pruner_name agp --pretrain_epochs 1 --prune_epochs 2

echo 'testing mean_activation pruning'
python3 model_prune_torch.py --pruner_name mean_activation --pretrain_epochs 1 --prune_epochs 1

#echo "testing lottery ticket pruning..."
#python3 lottery_torch_mnist_fc.py

Expand Down