AttributeError: 'collections.OrderedDict' object has no attribute 'load_state_dict'
时间: 2023-08-27 13:20:17 浏览: 246
这个错误出现的原因是因为'collections.OrderedDict'对象没有'load_state_dict'属性。根据引用和引用提到的信息,这个错误通常是由于在加载模型参数时没有使用正确的方法所导致的。在代码中,应该使用torch.load()方法来加载模型参数,并且使用model.load_state_dict()方法将参数加载到模型中。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [解决AttributeError: ‘collections.OrderedDict‘ object has no attribute ‘eval](https://blog.csdn.net/muye_IT/article/details/124956472)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *3* [AttributeError: ‘collections.OrderedDict‘ object has no attribute ‘eval](https://blog.csdn.net/weixin_39417324/article/details/122700769)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文