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

load state_dict #160

Closed
amkmpro opened this issue Mar 1, 2023 · 1 comment
Closed

load state_dict #160

amkmpro opened this issue Mar 1, 2023 · 1 comment

Comments

@amkmpro
Copy link

amkmpro commented Mar 1, 2023

Thank you for your code.
I want to use MobileNet2. I trained it (with e.g 10 epochs) and I save state_dict, but when I use it, I have an error.
Error is:
RuntimeError: Error(s) in loading state_dict for MobileNetV2:
Missing key(s) in state_dict: "conv1.weight", ...
Unexpected key(s) in state_dict: "module.conv1.weight", ....
Please help me.
Thanks in advance.

@amkmpro
Copy link
Author

amkmpro commented Mar 1, 2023

I found a solution. I use
torch.save(net.module.state_dict(), PATH)
instead of
torch.save(net.state_dict(), PATH)

@amkmpro amkmpro closed this as completed Mar 1, 2023
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