Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when loading the model saved #20

Open
ParusMajor60 opened this issue Mar 29, 2019 · 1 comment
Open

Error when loading the model saved #20

ParusMajor60 opened this issue Mar 29, 2019 · 1 comment

Comments

@ParusMajor60
Copy link

Hi,

I modified your code to train a model with my own dataset, and I am trying to load the model saved as "latest.pth" to do some tests. However, I am getting this error:

AttributeError: 'DenseNet' object has no attribute 'copy'

The code I use to load the model is:

net.load_state_dict(torch.load(checkpoint, map_location=lambda storage, loc: storage))

where checkpoint is the path to "latest.pth"

Any help would be appreciated.

Thanks

@feferna
Copy link

feferna commented May 5, 2019

Hi,

I modified your code to train a model with my own dataset, and I am trying to load the model saved as "latest.pth" to do some tests. However, I am getting this error:

AttributeError: 'DenseNet' object has no attribute 'copy'

The code I use to load the model is:

net.load_state_dict(torch.load(checkpoint, map_location=lambda storage, loc: storage))

where checkpoint is the path to "latest.pth"

Any help would be appreciated.

Thanks

I think you should load the model directly instead of the state_dict.

The following worked for me:
model = torch.load("./work/densenet.base/latest.pth")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants