Пример #1
0
    def _run_exp(self,
                 agent_class: AgentBase,
                 agent_type: str,
                 n_jobs: int = 1):
        # Arrange
        exp = AgentExperiment(
            name=os.path.join(self._tmp_dir.name, 'test_exp'),
            agent_class=agent_class,
            agent_config=self._agent_config(agent_type=agent_type,
                                            folder=self._tmp_dir.name),
            n_reps=3,
            n_jobs=n_jobs,
            training_options={
                "n_episodes": 4,
                "max_episode_steps": 4
            })

        # Act
        exp.run()

        # Assert
        self.assertEqual(3, len(exp._trained_agents))
        self.assertEqual(3, len(exp.agent_scores))
        for a in exp._trained_agents:
            self.assertEqual(4, len(a.training_history.history))
def run_exp(n_episodes: int = 500, max_episode_steps: int = 1500):
    exp = AgentExperiment(agent_class=RandomAgent,
                          agent_config=MountainCarConfig('random'),
                          n_reps=8,
                          n_jobs=4,
                          training_options={"n_episodes": n_episodes,
                                            "max_episode_steps": max_episode_steps})

    exp.run()
    exp.save(fn=f"{RandomAgent.__name__}_experiment.pkl")
def run_exp(n_episodes: int = 500, max_episode_steps: int = 1000):
    exp = AgentExperiment(agent_class=LinearQAgent,
                          agent_config=MountainCarConfig(agent_type='linear_1'),
                          n_reps=6,
                          n_jobs=6,
                          training_options={"n_episodes": n_episodes,
                                            "max_episode_steps": max_episode_steps})

    exp.run()
    exp.save(fn=f"{LinearQAgent.__name__}_experiment.pkl")
Пример #4
0
def run_exp(n_episodes: int = 1000, max_episode_steps: int = 500):
    exp = AgentExperiment(agent_class=ReinforceAgent,
                          agent_config=CartPoleConfig(agent_type='reinforce'),
                          n_reps=5,
                          n_jobs=6,
                          training_options={"n_episodes": n_episodes,
                                            "max_episode_steps": max_episode_steps,
                                            "update_every": 1})

    exp.run()
    exp.save(fn=f"{ReinforceAgent.__name__}_experiment.pkl")
Пример #5
0
def run_exp(agent_type: str,
            n_episodes: int = 500,
            max_episode_steps: int = 1000):
    exp = AgentExperiment(name=f"{agent_type} MountainCar",
                          agent_class=DeepQAgent,
                          n_reps=8,
                          n_jobs=8,
                          training_options={
                              "n_episodes": n_episodes,
                              "max_episode_steps": max_episode_steps
                          })

    exp.run()
    exp.save(fn=f"{DeepQAgent.__name__}_{agent_type}experiment.pkl")
Пример #6
0
def run_exp(agent_type: str,
            n_episodes: int = 1000,
            max_episode_steps: int = 500):
    exp = AgentExperiment(name=f"{agent_type} CartPole",
                          agent_class=ActorCriticAgent,
                          agent_config=CartPoleConfig(agent_type=agent_type),
                          n_reps=6,
                          n_jobs=6,
                          training_options={
                              "n_episodes": n_episodes,
                              "max_episode_steps": max_episode_steps
                          })

    exp.run()
    exp.save(fn=f"{ActorCriticAgent.__name__}_{agent_type}experiment.pkl")
def run_exp(agent_type: str, n_episodes: int = 400, max_episode_steps: int = 10000,
            model_mode: str = 'diff'):
    config = PongConfig(agent_type=agent_type, mode=model_mode)

    exp = AgentExperiment(name=f"{agent_type} {model_mode} Pong",
                          agent_class=ActorCriticAgent,
                          agent_config=config,
                          n_reps=3,
                          n_jobs=3,
                          gpu_memory_per_agent=1024,
                          training_options={"n_episodes": n_episodes,
                                            "verbose": 1,
                                            "max_episode_steps": max_episode_steps})

    exp.run()
    exp.save(fn=f"{DeepQAgent.__name__}_{agent_type}experiment.pkl")
def run_exp(n_episodes: int = 1000, max_episode_steps: int = 1000):
    gpu = VirtualGPU(256)

    exp = AgentExperiment(
        agent_class=ReinforceAgent,
        agent_config=MountainCarConfig(agent_type='reinforce'),
        n_reps=5,
        n_jobs=1 if gpu.on else 5,
        training_options={
            "n_episodes": n_episodes,
            "max_episode_steps": max_episode_steps,
            "update_every": 1
        })

    exp.run()
    exp.save(fn=f"{ReinforceAgent.__name__}_experiment.pkl")
Пример #9
0
def run_exp(agent_type: str,
            n_episodes: int = 1000,
            max_episode_steps: int = 10000):
    config = SpaceInvadersConfig(agent_type=agent_type, mode='stack')

    exp = AgentExperiment(name=f"{agent_type} Space Invaders",
                          agent_class=DeepQAgent,
                          agent_config=config,
                          n_reps=6,
                          n_jobs=6,
                          gpu_memory_per_agent=512,
                          training_options={
                              "n_episodes": n_episodes,
                              "verbose": 1,
                              "max_episode_steps": max_episode_steps
                          })

    exp.run()
    exp.save(fn=f"{DeepQAgent.__name__}_{agent_type}experiment.pkl")