Error(s) in loading state_dict for ResNet problem solving

When using the following command to load the model, an error will be reported, there are no keys:

model.load_state_dict(model_zoo.load_url(model_urls['resnet101']))
RuntimeError: Error(s) in loading state_dict for ResNet:

Missing key(s) in state_dict: "C1_down_channel.weight", "C1_down_channel.bias", "C2_down_channel.weight", "C2_down_channel.bias", 
 "C3_down_channel.weight", "C3_down_channel.bias", "C4_down_channel.weight", "C4_down_channel.bias", "C5_down_channel.weight", 
 "C5_down_channel.bias", "score_dsn1.weight", "score_dsn1.bias", "score_dsn2.weight", "score_dsn2.bias", "score_dsn3.weight", 
 "score_dsn3.bias", "score_dsn4.weight", "score_dsn4.bias", "score_dsn5.weight", "score_dsn5.bias", "score_final.weight", 
 "score_final.bias". 

You can use the following command to solve it, because the loaded model may lack some things that the existing model needs, and you can load it without using strict methods:

model.load_state_dict(model_zoo.load_url(model_urls['resnet101']), strict=False)

Guess you like

Origin blog.csdn.net/jiaoyangwm/article/details/118408337#comments_27838223