Comments (5)
I'm not sure what the issue is. The optimizer created in compress_classifier.py is passed to the file_config
method, and from there it is passed to the __init__
function of Quantizer
. So the instance maintained within Quantizer
- which is the one you refer to in the call self.optimizer.setstate
above, is the same optimizer as in the main application.
Are you running with the PACT quantizer and this is not what you're seeing? Is the optimizer in the main application not updating for you after the quantizer is created?
from distiller.
Thanks for your reply@guyjacob. The problem is what you said in the last sentence. When I run PACT quantizer, the optimizer in the compress_classifier.py is not updated after the quantizer is initialized. I simply print the optimizer.param_groups after calling file_config
. The reasonable result should print list containing two dict as returned by the _get_updated_optimizer_params_groups
in PACTQuantizer class. But it is still the optimizer before call file_config
. So I doubt this line self.optimizer.setstate({'param_groups': new_optimizer.param_groups}) can not change the optimizer passed to the file_config
method.
from distiller.
I tried printing the optimizer.param_groups
before and after the call to file_config
as you described, and I do see the second parameter group after the call to file_config
. See below - marked in bold.
Those single-element tensors are the tensors containing the alpha argument, which is initialized to 8.
Can you give the command-line you're using to run this?
Are you using the sample YAML we provided at distiller/examples/quantization/preact_resnet20_cifar_pact.yaml
or you're own?
2018-07-31 12:00:13,609 - Optimizer before: [{'lr': 0.1, 'dampening': 0, 'momentum': 0.9, 'nesterov': False, 'params': [Parameter containing: tensor([[[[ 0.0109, -0.1648, 0.0566], [-0.0265, -0.0163, 0.0223], [-0.0187, 0.1541, -0.0383]], ... ... tensor([ 0.0638, -0.0619, 0.0348, -0.0428, -0.0342, 0.0349, -0.1236, 0.0083, 0.0702, 0.0129], device='cuda:1')], 'weight_decay': 0.0001}] 2018-07-31 12:00:14,069 - Optimizer after: [{'lr': 0.1, 'dampening': 0, 'momentum': 0.9, 'nesterov': False, 'params': [Parameter containing: tensor([[[[ 0.0109, -0.1648, 0.0566], [-0.0265, -0.0163, 0.0223], [-0.0187, 0.1541, -0.0383]], ... ... tensor([ 0.0638, -0.0619, 0.0348, -0.0428, -0.0342, 0.0349, -0.1236, 0.0083, 0.0702, 0.0129], device='cuda:1')], 'initial_lr': 0.1, 'weight_decay': 0.0001}, {'lr': 0.1, 'dampening': 0, 'momentum': 0.9, 'nesterov': False, 'params': [Parameter containing: tensor([ 8.]), Parameter containing: tensor([ 8.]), Parameter containing: tensor([ 8.]), Parameter containing: tensor([ 8.]), Parameter containing: tensor([ 8.]), Parameter containing: tensor([ 8.]), Parameter containing: tensor([ 8.]), Parameter containing: tensor([ 8.]), Parameter containing: tensor([ 8.]), Parameter containing: tensor([ 8.]), Parameter containing: tensor([ 8.]), Parameter containing: tensor([ 8.]), Parameter containing: tensor([ 8.]), Parameter containing: tensor([ 8.]), Parameter containing: tensor([ 8.]), Parameter containing: tensor([ 8.]), Parameter containing: tensor([ 8.])], 'initial_lr': 0.1, 'weight_decay': 0.0001}]
from distiller.
Thank you very much for your patience. I found where the problem is and solved it. I used the old version config.py, so elif 'quantizer' in policy_def branch, i still have the following codes, therefore, it change the optimizer back.
if quantizer.train_with_fp_copy:
optimizer_type = type(optimizer)
new_optimizer = optimizer_type(model.parameters(), **optimizer.defaults)
optimizer.__setstate__({'param_groups': new_optimizer.param_groups})
One more little question is I think optimizer.setstate({'param_groups': new_optimizer.param_groups}) is equal to optimizer.param_groups=new_optimizer.param_groups. So why you choose the former rather than the latter.
from distiller.
Glad you found the issue.
Why use __setstate__
- don't recall 100%. It could be that setting param_groups
directly is good enough for our needs right now. But, __setstate__
is a bit more generic, and is also over-ridden by Optimizer
sub-classes which add specific logic. So it seems safer to use, in case we'll want to modify more than the param groups, and also in case some of the internal logic of the optimizers changes.
from distiller.
Related Issues (20)
- Could you provide the checkpoints for structural pruning experiments?
- checkpoints example in example jupyter-notebook download denied. HOT 1
- Support for PyTorch 1.7? HOT 3
- Can't install pyglet, even when i cloned it form github
- Higher than 8-bit Quantization not working properly!?
- yolo4 custom object detection deep compression
- Why can't I use multi-GPU training
- How can I use the distilled model in embedded device?
- Combining quantization and pruning in Distiller
- Issue running compress_classifier.py HOT 1
- Reduce the yolov3 model size of keras(.h5) or darknet(.weight)
- Quantization don't reduce the model file size
- How to train my original dataset in distiller? HOT 1
- Error running 'pip install mintapi' on Raspberry Pi
- --load-serialized will make model fail to prune HOT 1
- QAT for LSTM
- outdated requirements? HOT 2
- Sensitivity Analysis
- Does it support translation model?
- Load quantization aware model checkpoint (inference) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from distiller.