def trainer(fargs):
    trainer_id, args = fargs
    print("Trainer id", trainer_id, "started")
    # Create a Gym environment
    env = gym.make(args.env)

    # Set maximum episode length
    if args.episode_steps is not None:
        env._max_episode_steps = args.episode_steps

    # Get dimensionalities of actions and observations
    action_space_dim = get_space_dim(env.action_space)
    observation_space_dim = get_space_dim(env.observation_space)

    # Instantiate agent and its policy
    policy = Policy(observation_space_dim, action_space_dim)
    agent = Agent(policy)

    training_history = train(agent,
                             env,
                             args.train_episodes,
                             silent=True,
                             train_run_id=trainer_id,
                             early_stop=False)

    print("Trainer id", trainer_id, "finished")

    return training_history
Beispiel #2
0
def trainer(args):
    trainer_id, env = args
    print("Trainer id", trainer_id, "started")
    training_history = train(env, False, trainer_id)
    print("Trainer id", trainer_id, "finished")
    return training_history