我是靠谱客的博主 寂寞花瓣,这篇文章主要介绍Bug解决-Torch.save FileNotFoundError: [Errno 2] No such file or directory,现在分享给大家,希望可以做个参考。

Bug:

model_state_dict = {
            key.replace('module.', ''): tmp[key] for key in tmp if
            (('SearchNet' not in key) and ('_copy' not in key))
        }
        model_name = self.args.save_dir.strip('/')+'/model/model_latest.pth'
        torch.save(model_state_dict, model_name)
Torch.save FileNotFoundError: [Errno 2] No such file or directory

解决方法:

原先代码中default设置的路径是绝对路径,现在改为相对路径没有报错

parser.add_argument('--save_dir', type=str, default='./log/',
                    help='Directory to save log, arguments, models and images')

最后

以上就是寂寞花瓣最近收集整理的关于Bug解决-Torch.save FileNotFoundError: [Errno 2] No such file or directory的全部内容,更多相关Bug解决-Torch.save内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(43)

评论列表共有 0 条评论

立即
投稿
返回
顶部