AttributeError: 'DetectionModel' object has no attribute 'module
时间: 2023-10-05 12:07:46 浏览: 188
这个错误是因为在代码中使用了`module`属性,但是`DetectionModel`对象没有这个属性。根据引用中提供的解决方案,可以尝试将代码中的`.module`去掉。这样修改后的代码应该是`torch.save(self.netG.state_dict(), os.path.join(self.args.save_dir, f'G{str(self.iteration).zfill(7)}.pt'))`。这样做之后,再次运行代码应该就不会报错了。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [解决AttributeError: ‘model‘ object has no attribute ‘copy](https://blog.csdn.net/muye_IT/article/details/124956728)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [【报错记录】AttributeError: ‘xxx‘ object has no attribute ‘module](https://blog.csdn.net/hshudoudou/article/details/127435680)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文