",machine-learning,pytorch"/>

首页 > 解决方案 > 加载 PyTorch 模型并收到错误“AttributeError: Can't get attribute 'Model' on"

问题描述

我正在使用 torch.load() 加载 Pytorch 模型并收到错误“AttributeError: Can't get attribute 'Model' on <module ' main '>”。有谁知道是什么原因造成的?

标签: machine-learningpytorch

解决方案


已经保存的权重必须有一个类。您应该与加载的权重保持相同的类和文件体系结构。

因为隐式torch.load()使用模块。pickle


推荐阅读