MCPcopy
hub / github.com/microsoft/Swin-Transformer / save_checkpoint

Function save_checkpoint

utils_simmim.py:53–65  ·  view source on GitHub ↗
(config, epoch, model, max_accuracy, optimizer, lr_scheduler, scaler, logger)

Source from the content-addressed store, hash-verified

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

Callers 2

mainFunction · 0.90
mainFunction · 0.90

Calls 1

state_dictMethod · 0.80

Tested by

no test coverage detected