pytorch 版本不同造成 Missing key(s) in state_dict 和 Unexpected key(s) in state_dict

在服务器上面训练的pytoch模型保存的参数,在自己电脑上进行提示下面错误。刚开始感觉很无语,想着pytorch参数的格式应该有很好的兼容性,结果事实并非如此。

Missing key(s) in state_dict: "backbone.fpn.inner_blocks.0.weight",

Unexpected key(s) in state_dict: "backbone.fpn.inner_blocks.0.0.weight",

Missing key(s) in state_dict: "backbone.fpn.inner_blocks.0.weight", "backbone.fpn.inner_blocks.0.bias", "backbone.fpn.inner_blocks.1.weight", "backbone.fpn.inner_blocks.1.bias", "backbone.fpn.inner_blocks.2.weight", "backbone.fpn.inner_blocks.2.bias", "backbone.fpn.inner_blocks.3.weight", "backbone.fpn.inner_blocks.3.bias", "backbone.fpn.layer_blocks.0.weight", "backbone.fpn.layer_blocks.0.bias", "backbone.fpn.layer_blocks.1.weight", "backbone.fpn.layer_blocks.1.bias", "backbone.fpn.layer_blocks.2.weight", "backbone.fpn.layer_blocks.2.bias", "backbone.fpn.layer_blocks.3.weight", "backbone.fpn.layer_blocks.3.bias", "rpn.head.conv.weight", "rpn.head.conv.bias". 
	Unexpected key(s) in state_dict: "backbone.fpn.inner_blocks.0.0.weight", "backbone.fpn.inner_blocks.0.0.bias", "backbone.fpn.inner_blocks.1.0.weight", "backbone.fpn.inner_blocks.1.0.bias", "backbone.fpn.inner_blocks.2.0.weight", "backbone.fpn.inner_blocks.2.0.bias", "backbone.fpn.inner_blocks.3.0.weight", "backbone.fpn.inner_blocks.3.0.bias", "backbone.fpn.layer_blocks.0.0.weight", "backbone.fpn.layer_blocks.0.0.bias", "backbone.fpn.layer_blocks.1.0.weight", "backbone.fpn.layer_blocks.1.0.bias", "backbone.fpn.layer_blocks.2.0.weight", "backbone.fpn.layer_blocks.2.0.bias", "backbone.fpn.layer_blocks.3.0.weight", "backbone.fpn.layer_blocks.3.0.bias", "rpn.head.conv.0.0.weight", "rpn.head.conv.0.0.bias". 

服务器(Ubuntu 20.04)软件版本:

pytorch==1.12.1
torchvision==0.13.1
torchaudio==0.12.1
cudatoolkit=10.2

自己电脑(Windows 11)软件版本:

pytorch==1.11.0
torchvision==0.12.0
torchaudio==0.11.0
cudatoolkit=11.3

把自己电脑的软件版本更新,变成下面的版本就不存在上面的问题了

pytorch==1.12.1 
torchvision==0.13.1 
torchaudio==0.12.1 
cudatoolkit=11.3

你可能感兴趣的:(python,pytorch)