IntelLabs / distiller

Neural Network Distiller by Intel AI Lab: a Python package for neural network compression research. https://intellabs.github.io/distiller
Apache License 2.0
4.33k stars 799 forks source link

Model loading errors after quantization #509

Open Raso527 opened 4 years ago

Raso527 commented 4 years ago

Hello, when I loaded the model into it after training it as follows, I got an error. In this case, how should I deal with it?

training command

$ python compress_classifier.py --arch simplenet_cifar /torch/datasets/ -p=50 --epochs=3 --compress=../quantization/quant_aware_train/simplenet_cifar_dorefa.yaml -j 22 --lr 0.001 --wd 0.001 --vs 0 yaml file component

quantizers: dorefa_quantizer: class: DorefaQuantizer bits_activations: 4 bits_weights: 4

lr_schedulers: training_lr: Class: MultiStepLR MILESTONES: [60, 75] gamma: 0.2

Policies:

retraining command

python compress_classifier.py --arch simplenet_cifar /torch/datasets/ -p=50 --epochs=3 --exp-load-weights-from=logs/2020.05.12-150829/best.pth.tar --compress=.. /quantization/quant_aware_train/simplenet_cifar_dorefa.yaml -j 22 --lr 0.001 --wd 0.0001 --vs 0

errors

Traceback (most recent call last): File "compress_classifier.py", line 220, in main() File "compress_classifier.py", line 74, in main app = ClassifierCompressorSampleApp(args, script_dir=os.path.dirname(file)) File "compress_classifier.py", line 172, in init super().init(args, script_dir) File "/mnt/distiller/apputils/image_classifier.py", line 71, in init self.start_epoch, self.ending_epoch) = _init_learner(self.args) File "/mnt/distiller/apputils/image_classifier.py", line 402, in _init_learner model = apputils.load_lean_checkpoint(model, args.load_model_path, model_device=args.device) File "/mnt/distiller/apputils/checkpoint.py", line 92, in load_lean_checkpoint lean_checkpoint=True)[0] File "/mnt/distiller/apputils/checkpoint.py", line 224, in load_checkpoint quantizer = qmd['type'](model, **qmd['params']) TypeError: init() missing 1 required positional argument: 'optimizer'

best, Raso

Akimoto-Cris commented 3 years ago

I encountered the same problem before. Please consider trying out my solution in #535