-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Conversation
Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
model should be set to eval mode before the jit.trace call. Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
mask_conflict can fix the mask conflict of the layers that has channel dependency. This part should be called before the speedup function, so that, the speedup module can handle the model with residual connection/concat operations. Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
update the interface. if we alreay have the traced graph of the model we donnot need to trace the model again. Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
Add unittest for tools in analysis_utils to verify the correctness of the visulization, channel dependency, and mask conflict. Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
Thanks @zheng-ningxin , could you add doc (e.g., how to use the sensitivity tool, the requirement of this tool) under |
src/sdk/pynni/nni/analysis_utils/sensitivity/torch/sensitivity_analysis.py
Outdated
Show resolved
Hide resolved
Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
src/sdk/pynni/nni/compression/torch/utils/sensitivity_analysis.py
Outdated
Show resolved
Hide resolved
s_analyzer.export(os.path.join(outdir, filename)) | ||
``` | ||
|
||
Two key parameters of SensitivityAnalysis are model, and val_func. 'model' is the neural network that to be analyzed and the 'val_func' is the validation function that returns the model accuracy/loss/ or other metrics on the validation dataset. Due to different scenarios may have different ways to calculate the loss/accuracy, so users should prepare a function that returns the model accuracy/loss on the dataset and pass it to SensitivityAnalysis. |
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.
'model' -> model
'val_func' -> val_func
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.
Thanks~ I have fixed it, please review on the latest version~
Two key parameters of SensitivityAnalysis are model, and val_func. model is the neural network that to be analyzed and the val_func is the validation function that returns the model accuracy/loss/ or other metrics on the validation dataset. Due to different scenarios may have different ways to calculate the loss/accuracy, so users should prepare a function that returns the model accuracy/loss on the dataset and pass it to SensitivityAnalysis. | ||
SensitivityAnalysis can export the sensitivity results as a csv file usage is shown in the example above. | ||
|
||
Futhermore, users can specify the sparsities values used to prune for each layer by optinal parameter 'sparsities'. |
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.
optinal -> optional
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.
I have fixed several grammar errors, please review on the latest version, thanks~
minimize: The analysis stops when the validation metric return by the val_func lower than early_stop_value. | ||
maximize: The analysis stops when the validation metric return by the val_func larger than early_stop_value. | ||
dropped: The analysis stops when the validation metric has dropped by early_stop_value. | ||
raised: The analysis stops when the validation metric has raised by early_stop_value. |
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.
better to itemize these four values. you can check the rendered version.
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.
get confused about dropped
and raised
. what is the difference between dropped
/raised
and minimize
/maximize
?
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.
dropped is used in the cases that you want to stop when the accuracy has dropped by 5%, for example.
minimize is used in the cases that you want to keep the accuracy larger than a specified threshold during the analysis.
```python | ||
s_analyzer = SensitivityAnalysis(model=net, val_func=val, sparsities=[0.25, 0.5, 0.75], early_stop_mode='dropped', early_stop_value=0.1) | ||
``` | ||
If users only want to analyze several specified convolutional layers, users can specify the target conv layers by the 'sepcified_layers' parameter in analysis function. For example |
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.
how to specify a conv layer, using module name or module type?
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.
Sensitivity analyisis only analyze the conv layers, so we use the module name to specify the layers.
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.
then better to make it clear that the layers are specified through PyTorch module name.
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.
Sure, I'll update the doc and make this clear, thanks.
features.10,0.55468,0.5394,0.49576,0.4291,0.3591,0.28138,0.14256,0.05446,0.01578 | ||
``` | ||
|
||
## Topology |
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.
-> Topology Analysis
@@ -0,0 +1,109 @@ | |||
# Analysis Utils for Model Compression |
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.
could add
.. contents::
after this line
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.
in order for users to easily get what is the content of this doc
Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
Signed-off-by: Ningxin <Ningxin.Zheng@microsoft.com>
Add several analysis tools for the neural network: (1) sensitivity analysis, (2) topology analysis
Sensitivity Analysis Tool
Topology Analysis Tools
1 'shape_dependency.py' analyze the network architecture and find the layers that have shape dependencies.
2 'mask_conflict.py' this module can fix the mask conflict between the layers has channel dependency. This module should be called before the 'speedup' ,so that, the speedup module can handle the models with residual connections.