-
Notifications
You must be signed in to change notification settings - Fork 342
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
Training model cannot load properly #322
Comments
yes, I have the same problem!!! Do you have a solution now? |
Hi both, sorry for the lateness of reply. I think the latter case when you're loading from the "state_dict" key is the correct thing to do, however the model that you've instantiated has different constructor arguments from the model that these weights were saved from. You'll need to figure out what the parameters were exactly and be sure your class is instantiated correctly, if your weights are very old it's possible the class definition has changed and you may have to get the old version of the code from a previous MONAI release on Github and copy that into your project. |
谢谢你的提示!
Eric Kerfoot ***@***.***> 于2024年6月10日周一 19:42写道:
… Hi both, sorry for the lateness of reply. I think the latter case when
you're loading from the "state_dict" key is the correct thing to do,
however the model that you've instantiated has different constructor
arguments from the model that these weights were saved from. You'll need to
figure out what the parameters were exactly and be sure your class is
instantiated correctly, if your weights are very old it's possible the
class definition has changed and you may have to get the old version of the
code from a previous MONAI release on Github and copy that into your
project.
—
Reply to this email directly, view it on GitHub
<#322 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BDN4R34OE7NQB46IDWASUTTZGWGMFAVCNFSM6AAAAABJBXKC5WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJYGEYTQMRXG4>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I use a heart CT dataset to train this model,and I save this model when loss decrease to 0.7. However, I cannot load this pretrained model when I run test.py.
Then I changed the code "model_dict = torch.load(pretrained_pth)" to "model_dict = torch.load(pretrained_pth)["state_dict"]", it came to another problem:
The text was updated successfully, but these errors were encountered: