Exemplo n.º 1
0
def main(_seed, _run, env):
    torch.manual_seed(_seed)

    train_envs = build_envs(**env['train'])
    train_env = SampleEnv(train_envs)

    test_envs = build_envs(**env['test'])

    input_shape = train_env.observation_space.shape
    num_actions = train_env.action_space.n

    agent_params = DeepQAgentParams()
    add_params(params=agent_params, prefix='agent')
    add_params(params=agent_params.optimizer_params, prefix='opt')
    add_epsilon_params(params=agent_params)

    agent_params.sacred_run = _run
    agent_params.train_env = train_env
    agent_params.test_envs = test_envs

    online_q_net = build_net(input_shape=input_shape, num_actions=num_actions)
    target_q_net = build_net(input_shape=input_shape, num_actions=num_actions)
    agent_params.online_q_net = online_q_net
    agent_params.target_q_net = target_q_net

    agent = agent_params.make_agent()
    agent.run()
Exemplo n.º 2
0
def make_sampled_warehouse_env(artfiles, encode_onehot=False):
    envs = [
        make_warehouse_env(artfile, encode_onehot=encode_onehot)
        for artfile in artfiles
    ]
    env = SampleEnv(envs)
    return env
Exemplo n.º 3
0
def main(_seed, _run, env):
    torch.manual_seed(_seed)

    train_envs = build_envs(**env['train'])
    train_env = SampleEnv(train_envs)

    test_envs = build_envs(**env['test'])

    input_shape = train_env.observation_space.shape
    num_actions = train_env.action_space.n

    agent_params = ActorCriticAgentParams()
    add_params(params=agent_params, prefix='agent')
    add_params(params=agent_params.optimizer_params, prefix='opt')

    agent_params.sacred_run = _run
    agent_params.train_env = train_env
    agent_params.test_envs = test_envs

    policy_value_net = build_net(input_shape=input_shape,
                                 num_actions=num_actions)
    agent_params.policy_value_net = policy_value_net

    agent = agent_params.make_agent()
    agent.run()
Exemplo n.º 4
0
def main(_seed, _run, env):
    torch.manual_seed(_seed)

    train_envs, (kg_entities, _, num_node_feats,
                 num_edge_feats) = build_envs(**env['train'])
    num_entities = len(kg_entities)
    train_env = SampleEnv(train_envs)

    test_envs, _ = build_envs(**env['test'])

    input_shape = train_env.observation_space.shape
    num_actions = train_env.action_space.n

    agent_params = DeepQAgentParams()
    add_params(params=agent_params, prefix='agent')
    add_params(params=agent_params.optimizer_params, prefix='opt')
    add_epsilon_params(params=agent_params)
    add_stopping_params(params=agent_params)

    agent_params.sacred_run = _run
    agent_params.train_env = train_env
    agent_params.test_envs = test_envs

    agent_params.obs_filter = GraphEnv.batch_observations

    online_q_net = build_net(input_shape=input_shape,
                             num_actions=num_actions,
                             num_entities=num_entities,
                             num_node_feats=num_node_feats,
                             num_edge_feats=num_edge_feats)
    target_q_net = build_net(input_shape=input_shape,
                             num_actions=num_actions,
                             num_entities=num_entities,
                             num_node_feats=num_node_feats,
                             num_edge_feats=num_edge_feats)
    agent_params.online_q_net = online_q_net
    agent_params.target_q_net = target_q_net

    agent = agent_params.make_agent()
    agent.run()