Skip to content

How to load a model from model-only checkpoints? #1418

Answered by ShuhuaGao
ShuhuaGao asked this question in Q&A
Discussion options

You must be logged in to vote

Sorry for my ignorance..

In the model-only saving mode, the model.*.pth file contains exactly the state_dict of a model in pytorch. Supposing we have defined our model, simply do it like this to restore the trained model:

model.load_state_dict(torch.load(os.path.join(model_dir, 'model.best.pth'))

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ShuhuaGao
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant