Skip to content

when I load the pretrained_model, the shape of weights always mismatch #31

@garyliu0816

Description

@garyliu0816

Traceback (most recent call last):
File "train.py", line 184, in
main(parser.parse_args())
File "train.py", line 41, in main
model = models.create(args.net, pretrained=True, dim=args.dim)
File "D:\ProgramData\pyProjects\Pytorch-Deep-metric\models_init_.py", line 22, in create
return __factory[name](*args, **kwargs)
File "D:\ProgramData\pyProjects\Pytorch-Deep-metric\models\BN_Inception.py", line 521, in BN_Inception
model.load_state_dict(model_dict)
File "D:\Program Files\Anaconda3\envs\pytorch1\lib\site-packages\torch\nn\modules\module.py", line 769, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for BNInception:
size mismatch for conv1_7x7_s2_bn.weight: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for conv1_7x7_s2_bn.bias: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for conv1_7x7_s2_bn.running_mean: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).

How to solve this problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions