Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
dfe166e3
Unverified
Commit
dfe166e3
authored
Apr 06, 2020
by
chicm-ms
Committed by
GitHub
Apr 06, 2020
Browse files
Fix pruner issues (#2265)
parent
0fd8466b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
2 deletions
+11
-2
examples/model_compress/model_prune_torch.py
examples/model_compress/model_prune_torch.py
+1
-1
src/sdk/pynni/nni/compression/torch/pruners.py
src/sdk/pynni/nni/compression/torch/pruners.py
+1
-1
test/scripts/model_compression.sh
test/scripts/model_compression.sh
+9
-0
No files found.
examples/model_compress/model_prune_torch.py
View file @
dfe166e3
...
@@ -27,7 +27,7 @@ prune_config = {
...
@@ -27,7 +27,7 @@ prune_config = {
'model_name'
:
'naive'
,
'model_name'
:
'naive'
,
'pruner_class'
:
AGP_Pruner
,
'pruner_class'
:
AGP_Pruner
,
'config_list'
:
[{
'config_list'
:
[{
'initial_sparsity'
:
0
,
'initial_sparsity'
:
0
.
,
'final_sparsity'
:
0.8
,
'final_sparsity'
:
0.8
,
'start_epoch'
:
0
,
'start_epoch'
:
0
,
'end_epoch'
:
10
,
'end_epoch'
:
10
,
...
...
src/sdk/pynni/nni/compression/torch/pruners.py
View file @
dfe166e3
...
@@ -212,7 +212,7 @@ class AGP_Pruner(Pruner):
...
@@ -212,7 +212,7 @@ class AGP_Pruner(Pruner):
if
epoch
>
0
:
if
epoch
>
0
:
self
.
now_epoch
=
epoch
self
.
now_epoch
=
epoch
for
wrapper
in
self
.
get_modules_wrapper
():
for
wrapper
in
self
.
get_modules_wrapper
():
wrapper
.
if_calculated
.
copy_
(
torch
.
tensor
(
0
))
# pylint: disable=not-callabl
e
wrapper
.
if_calculated
=
Fals
e
class
SlimPruner
(
Pruner
):
class
SlimPruner
(
Pruner
):
"""
"""
...
...
test/scripts/model_compression.sh
View file @
dfe166e3
...
@@ -19,6 +19,15 @@ do
...
@@ -19,6 +19,15 @@ do
python3 model_prune_torch.py
--pruner_name
$name
--pretrain_epochs
1
--prune_epochs
1
python3 model_prune_torch.py
--pruner_name
$name
--pretrain_epochs
1
--prune_epochs
1
done
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..."
#echo "testing lottery ticket pruning..."
#python3 lottery_torch_mnist_fc.py
#python3 lottery_torch_mnist_fc.py
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment