def load(self, path):
    ' Loads parameters (but not training state) '
    states = torch.load(path)

    def recover_state(name, model, optimizer):
        state = model.state_dict()
        model_keys = set(state.keys())
        load_keys = set(states[name]['state_dict'].keys())
        if (model_keys != load_keys):
            print('NOTICE: DIFFERENT KEYS IN THE LISTEREN')
        state.update(states[name]['state_dict'])
        model.load_state_dict(state)
        if args.loadOptim:
            optimizer.load_state_dict(states[name]['optimizer'])
    all_tuple = [('encoder', self.encoder, self.encoder_optimizer), ('decoder', self.decoder, self.decoder_optimizer), ('critic', self.critic, self.critic_optimizer)]
    for param in all_tuple:
        recover_state(*param)
    return (states['encoder']['epoch'] - 1)
Loads parameters (but not training state)
def load(self, path):
    '  '
    states = torch.load(path)

    def recover_state(name, model, optimizer):
        state = model.state_dict()
        model_keys = set(state.keys())
        load_keys = set(states[name]['state_dict'].keys())
        if (model_keys != load_keys):
            print('NOTICE: DIFFERENT KEYS IN THE LISTEREN')
        state.update(states[name]['state_dict'])
        model.load_state_dict(state)
        if args.loadOptim:
            optimizer.load_state_dict(states[name]['optimizer'])
    all_tuple = [('encoder', self.encoder, self.encoder_optimizer), ('decoder', self.decoder, self.decoder_optimizer), ('critic', self.critic, self.critic_optimizer)]
    for param in all_tuple:
        recover_state(*param)
    return (states['encoder']['epoch'] - 1)