in mico/model/mico.py [0:0]
def load(self, suffix="", subprocess_index=0):
"""Load the existing model (previously saved on disk).
If there is optimizer infomation (e.g., for Adam), we also load it for resuming training.
Parameters
----------
suffix : string
The model path for loading will be `self.hparams.model_path + suffix`.
Different models will be loaded if you set different `suffix`.
"""
checkpoint = torch.load(self.hparams.model_path + suffix,
map_location=torch.device(subprocess_index)) \
if self.hparams.cuda \
else torch.load(self.hparams.model_path + suffix,
map_location=torch.device('cpu'))
if checkpoint['hparams'].cuda and not self.hparams.cuda:
checkpoint['hparams'].cuda = False
if not self.hparams.not_resume_hparams:
self.__init__(checkpoint['hparams'])
self.resume_epoch = checkpoint['epoch']
self.load_state_dict(checkpoint['state_dict'])
if 'optimizer' in checkpoint:
self.optimizers = checkpoint['optimizer']
if 'current_iteration_number' in checkpoint:
self.resume_iteration = checkpoint['current_iteration_number']
else:
self.resume_iteration = 0