Error(s) in loading state_dict for ResNet 问题解决
生活随笔
收集整理的這篇文章主要介紹了
Error(s) in loading state_dict for ResNet 问题解决
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
當使用如下命令加載模型的時候,會報錯,沒有一些 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".則可以使用如下命令來解決,因為 load 的模型可能會缺少一些現有模型需要的東西,不使用嚴格的方式來 load 即可:
model.load_state_dict(model_zoo.load_url(model_urls['resnet101']), strict=False)總結
以上是生活随笔為你收集整理的Error(s) in loading state_dict for ResNet 问题解决的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: AirTag被主人用来追踪宠物:结果狗狗
- 下一篇: 【Transformer】CSWin T