-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix pruner bugs and add model compression README #1624
Conversation
pruner.update_epoch(epoch) | ||
|
||
pruner.update_epoch(epoch + 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's discuss whether epoch should start from 0 or 1 next time.
@@ -2,7 +2,7 @@ | |||
import torch | |||
from .compressor import Pruner | |||
|
|||
__all__ = ['LevelPruner', 'AGP_Pruner', 'SensitivityPruner'] | |||
__all__ = ['LevelPruner', 'AGP_Pruner'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you removed sensitivitypruner, so please update doc accordingly
examples/model_compress/README.md
Outdated
python main_torch_pruner.py | ||
``` | ||
|
||
Model compression can be configured in 2 ways |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example uses AGP Pruner. Initiating a pruner needs a user provided configuration which can be provided in two ways:
examples/model_compress/README.md
Outdated
|
||
Model compression can be configured in 2 ways | ||
|
||
- By reading ```configure_example.yaml```, this can make codes clean when your configuration is complicated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
codes -> code
examples/model_compress/README.md
Outdated
pruner = AGP_Pruner(configure_list) | ||
``` | ||
|
||
Please notice that when ```pruner(model)``` called, our model compression codes will be **automatically injected** and you can fine-tune your model **without** any modifications, masked weights **won't** be updated any more during fine tuning. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When pruner(model)
is called, your model is injected with masks as embedded operations. For example, a layer takes a weight as input, we will insert an operation between the weight and the layer, this operation takes the weight as input and outputs a new weight applied by the mask. Thus, the masks are applied at any time the computation goes through the operations. You can fine-tune your model without any modifications.
@@ -8,7 +8,6 @@ We have provided two naive compression algorithms and four popular ones for user | |||
|---|---| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“We have provided two naive compression algorithms and four popular ones for users, including three pruning algorithms and three quantization algorithms:” this line should also be updated
@@ -48,7 +48,7 @@ from nni.compression.tensorflow import AGP_Pruner | |||
config_list = [{ | |||
'initial_sparsity': 0, | |||
'final_sparsity': 0.8, | |||
'start_epoch': 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the meaning of start_epoch=0, end_epoch=10?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@QuanluZhang start_epoch=0, end_epoch=10 means pruning starts from epoch 0 and ends at 10, previous default start_epoch=1 in the algorithm but we usually start from 0, so I modified them all.
fix pruner bugs and add model compression README