Exemplo n.º 1
0
    qnet_conf.gnn_conf = gnn_conf
    actor_conf.gnn_conf = gnn_conf

    buffer_conf = NstepInputMemoryConfig(memory_conf={'use_return': True})
    brain_conf = QmixActorCriticBrainConfig(brain_conf={'use_double_q': True})

    sample_spec = buffer_conf.memory_conf['spec']
    num_hist_steps = buffer_conf.memory_conf['N']

    run_device = 'cpu'
    fit_device = 'cuda' if torch.cuda.is_available() else 'cpu'

    if use_attention:
        raise NotImplementedError
    else:
        mixer_gnn_conf = RelationalGraphNetworkConfig(
            gnn_conf={'spectral_norm': spectral_norm})
    mixer_ff_conf = FeedForwardConfig(
        mlp_conf={'spectral_norm': spectral_norm})

    agent_conf = QmixActorCriticAgentConf(agent_conf={'use_clipped_q': True})

    agent = QmixActorCriticAgent(conf=agent_conf,
                                 actor_conf=actor_conf,
                                 qnet_conf=qnet_conf,
                                 mixer_gnn_conf=mixer_gnn_conf,
                                 mixer_ff_conf=mixer_ff_conf,
                                 brain_conf=brain_conf,
                                 buffer_conf=buffer_conf)

    agent.to(run_device)
Exemplo n.º 2
0
        mixer_gnn_conf = RelationalNetworkConfig(
            gnn_conf={
                'model_dim': mixer_input_dim,
                'num_layers': mixer_num_layer,
                'num_neurons': num_neurons,
                'num_relations': num_relations,
                'num_head': num_attn_head,
                'use_multi_node_types': False
            })
    else:
        mixer_gnn_conf = RelationalGraphNetworkConfig(
            gnn_conf={
                'spectral_norm': spectral_norm,
                'model_dim': mixer_input_dim,
                'num_layers': mixer_num_layer,
                'use_concat': use_concat_input_gnn,
                'num_neurons': num_neurons,
                'use_multi_node_types': False,
                'node_update_types': mixer_node_update_types,
                'edge_update_types': mixer_edge_update_types,
                'use_noisy': use_noisy
            })

    mixer_ff_conf = FeedForwardConfig(
        mlp_conf={
            'spectral_norm': spectral_norm,
            'input_dimension': mixer_input_dim,
            'num_neurons': num_neurons,
            'use_noisy': use_noisy
        })

    sup_mixer_conf = SupQmixerConf(nn_conf={
Exemplo n.º 3
0
    buffer_conf = NstepInputMemoryConfig(memory_conf={'use_return': True})
    brain_conf = QmixBrainConfig(brain_conf={'use_double_q': True},
                                 fit_conf={'tau': 0.9})

    sample_spec = buffer_conf.memory_conf['spec']
    num_hist_steps = buffer_conf.memory_conf['N']

    run_device = 'cpu'
    fit_device = 'cuda' if torch.cuda.is_available() else 'cpu'

    if use_attention:
        raise NotImplementedError
    else:
        mixer_gnn_conf = RelationalGraphNetworkConfig(
            gnn_conf={
                'spectral_norm': spectral_norm,
                'model_dim': node_input_dim
            })
    mixer_ff_conf = FeedForwardConfig(mlp_conf={
        'spectral_norm': spectral_norm,
        'input_dimension': node_input_dim
    })

    agent_conf = QmixAgentConf(agent_conf={'use_clipped_q': True})

    agent = QmixAgent(conf=agent_conf,
                      qnet_conf=qnet_conf,
                      mixer_gnn_conf=mixer_gnn_conf,
                      mixer_ff_conf=mixer_ff_conf,
                      brain_conf=brain_conf,
                      buffer_conf=buffer_conf)
Exemplo n.º 4
0
    fit_device = 'cuda' if torch.cuda.is_available() else 'cpu'

    if use_attention:
        mixer_gnn_conf = RelationalNetworkConfig(
            gnn_conf={
                'model_dim': mixer_input_dim,
                'num_layers': mixer_num_layer,
                'num_neurons': num_neurons,
                'num_relations': num_relations,
                'num_head': num_attn_head
            })
    else:
        mixer_gnn_conf = RelationalGraphNetworkConfig(
            gnn_conf={
                'spectral_norm': spectral_norm,
                'model_dim': mixer_input_dim,
                'num_layers': mixer_num_layer,
                'use_concat': use_concat_input_gnn,
                'num_neurons': num_neurons
            })

    mixer_ff_conf = FeedForwardConfig(
        mlp_conf={
            'spectral_norm': spectral_norm,
            'input_dimension': mixer_input_dim,
            'num_neurons': num_neurons
        })

    sup_mixer_conf = SupQmixerConf(nn_conf={
        'spectral_norm': spectral_norm,
        'input_dimension': mixer_input_dim,
        'num_neurons': num_neurons
Exemplo n.º 5
0
            n_hist_feature=n_hist_feature,
            n_curr_graph=n_curr_graph,
            n_curr_feature=n_curr_feature,
            n_maximum_num_enemy=n_maximum_num_enemy,
            actions=actions,
            rewards=rewards,
            dones=dones)

        return fit_return_dict


if __name__ == "__main__":
    from sc2rl.rl.networks.RelationalGraphNetwork import RelationalGraphNetworkConfig
    from sc2rl.rl.networks.FeedForward import FeedForwardConfig
    from sc2rl.memory.n_step_memory import NstepInputMemoryConfig
    from sc2rl.rl.networks.MultiStepInputGraphNetwork import MultiStepInputGraphNetworkConfig

    conf = QmixAgentConf()
    actor_conf = ActorModuleConfig()

    qnet_conf = MultiStepInputQnetConfig()
    qnet_conf.gnn_conf = MultiStepInputGraphNetworkConfig()

    mixer_gnn_conf = RelationalGraphNetworkConfig()
    mixer_ff_conf = FeedForwardConfig()
    brain_conf = QmixActorCriticBrainConfig()
    buffer_conf = NstepInputMemoryConfig()

    QmixAgent(conf, actor_conf, qnet_conf, mixer_gnn_conf, mixer_ff_conf,
              brain_conf, buffer_conf)