Open scpoppin1207 opened 1 week ago
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 👍
I don't see any function or parameters to load from existed checkpoint.