DeepLabV3Plus-Pytorch icon indicating copy to clipboard operation
DeepLabV3Plus-Pytorch copied to clipboard

使用预训练加载模型,在这一行出现如下报错

Open wudandi opened this issue 3 years ago • 0 comments

https://github.com/VainF/DeepLabV3Plus-Pytorch/blob/e0ee4769d676e093d56b2ddad963300c4b61c0b1/main.py#L294

Traceback (most recent call last): File "main.py", line 383, in main() File "main.py", line 294, in main model.load_state_dict(checkpoint["model_state"]) File "/home/ubuntu/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1483, in load_state_dict self.class.name, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for DeepLabV3: Missing key(s) in state_dict: "classifier.aspp.convs.1.0.body.0.weight", "classifier.aspp.convs.1.0.body.1.weight", "classifier.aspp.convs.2.0.body.0.weight", "classifier.aspp.convs.2.0.body.1.weight", "classifier.aspp.convs.3.0.body.0.weight", "classifier.aspp.convs.3.0.body.1.weight", "classifier.classifier.0.body.0.weight", "classifier.classifier.0.body.1.weight". Unexpected key(s) in state_dict: "classifier.aspp.convs.1.0.weight", "classifier.aspp.convs.2.0.weight", "classifier.aspp.convs.3.0.weight", "classifier.classifier.0.weight". size mismatch for classifier.classifier.3.weight: copying a param with shape torch.Size([21, 256, 1, 1]) from checkpoint, the shape in current model is torch.Size([2, 256, 1, 1]). size mismatch for classifier.classifier.3.bias: copying a param with shape torch.Size([21]) from checkpoint, the shape in current model is torch.Size([2])

wudandi avatar Dec 05 '21 12:12 wudandi