def __init__(self, env, config=None): super(AbstractDQNAgent, self).__init__(config) self.env = env assert isinstance(env.action_space, spaces.Discrete) or isinstance(env.action_space, spaces.Tuple), \ "Only compatible with Discrete action spaces." self.memory = ReplayMemory(self.config) self.exploration_policy = exploration_factory(self.config["exploration"], self.env.action_space) self.training = True self.previous_state = None
def __init__(self, env, config=None): super(AbstractDQNAgent, self).__init__(config) self.env = env assert isinstance( env.action_space, spaces.Discrete), "Only compatible with Discrete action spaces." self.config["model"]["in"] = int(np.prod(env.observation_space.shape)) self.config["model"]["out"] = env.action_space.n self.memory = ReplayMemory(self.config) self.exploration_policy = exploration_factory( self.config["exploration"], self.env.action_space) self.training = True self.previous_state = None
def eval(self): self.training = False self.config['exploration']['method'] = "Greedy" self.exploration_policy = exploration_factory( self.config["exploration"], self.env.action_space)