MCPcopy Create free account
hub / github.com/LeapLabTHU/DAT / save_checkpoint

Function save_checkpoint

utils.py:51–62  ·  view source on GitHub ↗
(config, epoch, model, max_accuracy, optimizer, lr_scheduler, logger)

Source from the content-addressed store, hash-verified

49
50
51def save_checkpoint(config, epoch, model, max_accuracy, optimizer, lr_scheduler, logger):
52 save_state = {'model': model.state_dict(),
53 'optimizer': optimizer.state_dict(),
54 'lr_scheduler': lr_scheduler.state_dict(),
55 'max_accuracy': max_accuracy,
56 'epoch': epoch,
57 'config': config}
58
59 save_path = os.path.join(config.OUTPUT, f'ckpt_epoch_{epoch}.pth')
60 logger.info(f"{save_path} saving......")
61 torch.save(save_state, save_path)
62 logger.info(f"{save_path} saved !!!")
63
64
65def get_grad_norm(parameters, norm_type=2):

Callers 2

mainFunction · 0.90
mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected