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

Failed to load pretrained weight file in densenet #1

Open
randomstate4242 opened this issue Jun 14, 2022 · 0 comments
Open

Failed to load pretrained weight file in densenet #1

randomstate4242 opened this issue Jun 14, 2022 · 0 comments

Comments

@randomstate4242
Copy link

randomstate4242 commented Jun 14, 2022

I saved weight file as below.

import torch
from torchvision import models

// Download and load the pre-trained model
model = models.densenet121(pretrained=True)
print(model)

// Set upgrading the gradients to False
for param in model.parameters():
param.requires_grad = False

modelname = 'densenet121.pt'
example_input = torch.rand(1, 3, 224, 224)
script_module = torch.jit.trace(model, example_input)
script_module.save(modelname)

and then,

DenseNet model;
std::cout << model << std::endl;
model.apply(init_weights);
torch::load(model, "densenet121.pt"); <= void load(Value& value, LoadFromArgs&&... args) { ... archive >> value; } unhandled exception happened ㅠㅠ

image

Thank you in advance for your future help^^

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

1 participant