-
Notifications
You must be signed in to change notification settings - Fork 18
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
Can this model resume from former checkpoint? #20
Comments
Hi, you can add/modify the following code to the appropriate place to resume training: # save meta-data
checkpoint = {'model': model.state_dict(), 'optim': optim.state_dict(), \
'epoch': epoch, 'lr': scheduler.state_dict(),}
torch.save(checkpoint, path)
# load meta-data
checkpoint = torch.load(path)
model.load_state_dict(checkpoint['model'])
optim.load_state_dict(checkpoint['optim'])
epoch = checkpoint(['epoch'])
scheduler = CosineAnnealingLR(optim, args.epoch, eta_min=1.0e-7, last_epoch=epoch) You may also refer to the pytorch tutorial. |
Thxs 👍 |
model.load_state_dict(checkpoint['model']) |
It seems that there's no key named "model" |
If you are using the original save code, the weights of the model are not wrapped in the torch.save(model.state_dict(), os.path.join(args.save_path, 'SAM2-UNet-%d.pth' % (epoch + 1))) The new save code above wraps the state dict in the checkpoint = {'model': model.state_dict(), 'optim': optim.state_dict(), \
'epoch': epoch, 'lr': scheduler.state_dict(),}
torch.save(checkpoint, path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't see any function or parameters to load from existed checkpoint.
The text was updated successfully, but these errors were encountered: