Fixed session call
@@ -10,7 +10,7 @@ class ModelToolbox:
self.optimizer_class = optimizer_class
- def save_model(self, session_path, model_info):
+ def save_model(self, miner_path, model_info):
"""Saves the model locally.
Args:
@@ -32,8 +32,8 @@ class ModelToolbox:
if 'optimizer_state_dict' not in model_info.keys():
raise ModelInformationNotFoundException("Missing 'optimizer' in torch save dict")
- logger.info( 'Saving/Serving model: epoch: {}, loss: {}, path: {}/model.torch'.format(model_info['epoch'], model_info['loss'], session_path))
- torch.save(model_info,"{}/model.torch".format(session_path))
+ logger.info( 'Saving/Serving model: epoch: {}, loss: {}, path: {}/model.torch'.format(model_info['epoch'], model_info['loss'], miner_path))
+ torch.save(model_info,"{}/model.torch".format(miner_path))
except ModelInformationNotFoundException as e:
logger.error("Encountered exception trying to save model: {}", e)
@@ -46,18 +46,18 @@ class ModelToolbox:
optimizer (:obj:`torch.optim`) : Model optimizer that was saved with the model.
"""
model = self.model_class( config )
- optimizer = self.optimizer_class(model.parameters(), lr = config.session.learning_rate, momentum=config.session.momentum)
+ optimizer = self.optimizer_class(model.parameters(), lr = config.miner.learning_rate, momentum=config.miner.momentum)
try:
- checkpoint = torch.load("{}/model.torch".format(config.session.full_path))
+ checkpoint = torch.load("{}/model.torch".format(config.miner.full_path))
model.load_state_dict(checkpoint['model_state_dict'])
optimizer.load_state_dict(checkpoint['optimizer_state_dict'])
epoch = checkpoint['epoch']
loss = checkpoint['loss']
- logger.info( 'Reloaded model: epoch: {}, loss: {}, path: {}/model.torch'.format(epoch, loss, config.session.full_path))
+ logger.info( 'Reloaded model: epoch: {}, loss: {}, path: {}/model.torch'.format(epoch, loss, config.miner.full_path))
except Exception as e:
- logger.warning ( 'Exception {}. Could not find model in path: {}/model.torch', e, config.session.full_path )
+ logger.warning ( 'Exception {}. Could not find model in path: {}/model.torch', e, config.miner.full_path )
return model, optimizer
