-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errors in loading state_dict (size mismatch) #71
Comments
I'm the same with you. |
same error:
|
This is probably because of the change in class_num parameter. If you changed the characters the model is going to train on, you cannot use the pretrained model. Better go with xavier initialization |
Hey, can you please help me?
I was trying to train the model on custom dataset following instructions from this issue (deleted LPRDataLoader.getitem and modified CHARS, though did not change T_length).
I am running the code from Google Colaboratory and here is the issue:
Successful to build network!
RuntimeError Traceback (most recent call last)
in ()
154
155 if name == "main":
--> 156 test()
1 frames
/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py in load_state_dict(self, state_dict, strict)
1496 if len(error_msgs) > 0:
1497 raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
-> 1498 self.class.name, "\n\t".join(error_msgs)))
1499 return _IncompatibleKeys(missing_keys, unexpected_keys)
1500
RuntimeError: Error(s) in loading state_dict for LPRNet:
size mismatch for backbone.20.weight: copying a param with shape torch.Size([68, 256, 13, 1]) from checkpoint, the shape in current model is torch.Size([37, 256, 13, 1]).
size mismatch for backbone.20.bias: copying a param with shape torch.Size([68]) from checkpoint, the shape in current model is torch.Size([37]).
size mismatch for backbone.21.weight: copying a param with shape torch.Size([68]) from checkpoint, the shape in current model is torch.Size([37]).
size mismatch for backbone.21.bias: copying a param with shape torch.Size([68]) from checkpoint, the shape in current model is torch.Size([37]).
size mismatch for backbone.21.running_mean: copying a param with shape torch.Size([68]) from checkpoint, the shape in current model is torch.Size([37]).
size mismatch for backbone.21.running_var: copying a param with shape torch.Size([68]) from checkpoint, the shape in current model is torch.Size([37]).
size mismatch for container.0.weight: copying a param with shape torch.Size([68, 516, 1, 1]) from checkpoint, the shape in current model is torch.Size([37, 485, 1, 1]).
size mismatch for container.0.bias: copying a param with shape torch.Size([68]) from checkpoint, the shape in current model is torch.Size([37]).
Code itself:
def test():
args = get_parser()
lprnet = build_lprnet(lpr_max_len=args.lpr_max_len, phase=args.phase_train, class_num=len(CHARS), dropout_rate=args.dropout_rate)
device = torch.device("cuda:0" if args.cuda else "cpu")
lprnet.to(device)
print("Successful to build network!")
What should I do?..
The text was updated successfully, but these errors were encountered: