Esempio n. 1
0
 def __init__(self,
              model_class,
              model=None,
              env=None,
              exploration=None,
              gamma=0.99,
              memory_size=10000,
              batch_size=64,
              target_update_frequency=10,
              saving_dir=None):
     """
     base class for lstm dqn agent
     :param model_class: sub class of torch.nn.Module. class reference of the model
     :param model: initial model of the policy net. could be None if loading from checkpoint
     :param env: environment
     :param exploration: exploration object. Must have function value(step) which returns e
     :param gamma: gamma
     :param memory_size: size of the memory
     :param batch_size: size of the mini batch for one step update
     :param target_update_frequency: the frequency for updating target net (in episode)
     :param saving_dir: the directory for saving checkpoint
     """
     DQNAgent.__init__(self, model_class, model, env, exploration, gamma,
                       memory_size, batch_size, target_update_frequency,
                       saving_dir)
     self.memory = EpisodicReplayMemory(memory_size)
     self.hidden_size = 0
     if self.policy_net:
         self.hidden_size = self.policy_net.hidden_size
     self.hidden = None