PAMS icon indicating copy to clipboard operation
PAMS copied to clipboard

Testing error

Open xxktju opened this issue 4 years ago • 2 comments

I build a new model, after quantization aware training this model, we meet the following test error. 捕获 can u give me some suggestions?

xxktju avatar Feb 02 '21 09:02 xxktju

@xxktju Hi, it seems the shape of max_val in the saved checkpoint is inconsistent with the model state_dict. You can try to preprocess the saved checkpoint like:

ckpt = torch.load(ckpt_path)['state_dict']
for k, v in ckpt.items():
    if 'max_val' in k:
        ckpt[k] = v.unsqueeze(0)
model.load_state_dict(ckpt)

colorjam avatar Feb 10 '21 05:02 colorjam

@xxktju Hi, it seems the shape of max_val in the saved checkpoint is inconsistent with the model state_dict. You can try to preprocess the saved checkpoint like:

ckpt = torch.load(ckpt_path)['state_dict']
for k, v in ckpt.items():
    if 'max_val' in k:
        ckpt[k] = v.unsqueeze(0)
model.load(ckpt)

Hi, thanks for your suggestion, I recently concurred with this problem and solved by following your guide. 👍 However, the last sentence should be "model.load_state_dict(ckpt)" I think. Thank you once again!

MonicaHui avatar Mar 27 '21 08:03 MonicaHui