Ejemplo n.º 1
0
def get_default_values(spatial_dimensions):
    """get_default_values

    The initial values for the TensorFlow features.

    :param spatial_dimensions: The size of the spatial dimension.
    """

    s_d = spatial_dimensions

    feature_list = [
        (FEATURE_KEYS.minimap_numeric, tf.float32,
         [None, s_d, s_d, ObsProcessor.N_MINIMAP_CHANNELS]),
        (FEATURE_KEYS.screen_numeric, tf.float32,
         [None, s_d, s_d, ObsProcessor.N_SCREEN_CHANNELS]),
        (FEATURE_KEYS.non_spatial_features, tf.float32,
         [None, ObsProcessor.N_NON_SPATIAL]),
        (FEATURE_KEYS.screen_unit_type, tf.int32, [None, s_d, s_d]),
        (FEATURE_KEYS.is_spatial_action_available, tf.float32, [None]),
        (FEATURE_KEYS.available_action_ids, tf.float32,
         [None, len(actions.FUNCTIONS)]),
        (FEATURE_KEYS.selected_spatial_action, tf.int32, [None, 2]),
        (FEATURE_KEYS.selected_action_id, tf.int32, [None]),
        (FEATURE_KEYS.value_target, tf.float32, [None]),
        (FEATURE_KEYS.player_relative_screen, tf.int32, [None, s_d, s_d]),
        (FEATURE_KEYS.player_relative_minimap, tf.int32, [None, s_d, s_d]),
        (FEATURE_KEYS.advantage, tf.float32, [None])
    ]

    return AgentInputTuple(
        **{
            name: tf.placeholder(dtype, shape, name)
            for name, dtype, shape in feature_list
        })
Ejemplo n.º 2
0
def _get_placeholders(spatial_dim):
    sd = spatial_dim
    feature_list = [
        (FEATURE_KEYS.alt0_grass, tf.float32, [None, 20, 20]),
        (FEATURE_KEYS.alt0_bush, tf.float32, [None, 20, 20]),
    # FEATURE_KEYS.available_action_ids: get_available_actions_flags(obs),
        (FEATURE_KEYS.alt0_drone, tf.float32, [None, 20, 20]),
        (FEATURE_KEYS.alt0_hiker, tf.float32, [None, 20, 20]),
        (FEATURE_KEYS.alt1_pine, tf.float32, [None, 20, 20]),  # numpy.array is redundant
        (FEATURE_KEYS.alt1_pines, tf.float32, [None, 20, 20]),
        (FEATURE_KEYS.alt1_drone, tf.float32, [None, 20, 20]),
        (FEATURE_KEYS.alt2_drone, tf.float32, [None, 20, 20]),
        (FEATURE_KEYS.alt3_drone, tf.float32, [None, 20, 20]),
        (FEATURE_KEYS.minimap_numeric, tf.float32, [None, sd, sd, ObsProcesser.N_MINIMAP_CHANNELS]),
        (FEATURE_KEYS.screen_numeric, tf.float32, [None, sd, sd, ObsProcesser.N_SCREEN_CHANNELS]),
        (FEATURE_KEYS.screen_unit_type, tf.int32, [None, sd, sd]),
        (FEATURE_KEYS.is_spatial_action_available, tf.float32, [None]),
        (FEATURE_KEYS.available_action_ids, tf.float32, [None, len(actions.FUNCTIONS)]),
        (FEATURE_KEYS.selected_spatial_action, tf.int32, [None, 2]),
        (FEATURE_KEYS.selected_action_id, tf.int32, [None]),
        (FEATURE_KEYS.value_target, tf.float32, [None]),
        (FEATURE_KEYS.rgb_screen, tf.float32, [None, 100, 100, 3]),
        (FEATURE_KEYS.alt_view, tf.float32, [None, 100, 100, 3]),
        (FEATURE_KEYS.player_relative_screen, tf.int32, [None, sd, sd]),
        (FEATURE_KEYS.player_relative_minimap, tf.int32, [None, sd, sd]),
        (FEATURE_KEYS.advantage, tf.float32, [None]),
    ]
    return AgentInputTuple(
        **{name: tf.placeholder(dtype, shape, name) for name, dtype, shape in feature_list}
    )
Ejemplo n.º 3
0
def _get_placeholders(spatial_dim):
    sd = spatial_dim
    feature_list = [
        (FEATURE_KEYS.minimap_numeric, tf.float32, [None, sd, sd, ObsProcesser.N_MINIMAP_CHANNELS]),
        (FEATURE_KEYS.screen_numeric, tf.float32, [None, sd, sd, ObsProcesser.N_SCREEN_CHANNELS]),
        (FEATURE_KEYS.screen_unit_type, tf.int32, [None, sd, sd]),
        (FEATURE_KEYS.is_spatial_action_available, tf.float32, [None]),
        (FEATURE_KEYS.available_action_ids, tf.float32, [None, len(actions.FUNCTIONS)]),
        (FEATURE_KEYS.selected_spatial_action, tf.int32, [None, 2]),
        (FEATURE_KEYS.selected_action_id, tf.int32, [None]),
        (FEATURE_KEYS.value_target, tf.float32, [None]),
        (FEATURE_KEYS.player_relative_screen, tf.int32, [None, sd, sd]),
        (FEATURE_KEYS.player_relative_minimap, tf.int32, [None, sd, sd]),
        (FEATURE_KEYS.advantage, tf.float32, [None])
    ]
    return AgentInputTuple(
        **{name: tf.placeholder(dtype, shape, name) for name, dtype, shape in feature_list}
    )
Ejemplo n.º 4
0
def _get_placeholders(spatial_dim, nsteps, nenvs, policy_type, obs_d):
    sd = spatial_dim
    if policy_type == 'MetaPolicy':
        feature_list = [
            (FEATURE_KEYS.alt0_grass, tf.float32, [None, 20, 20]),
            (FEATURE_KEYS.alt0_bush, tf.float32, [None, 20, 20]),
            # FEATURE_KEYS.available_action_ids: get_available_actions_flags(obs),
            (FEATURE_KEYS.alt0_drone, tf.float32, [None, 20, 20]),
            (FEATURE_KEYS.alt0_hiker, tf.float32, [None, 20, 20]),
            (FEATURE_KEYS.alt1_pine, tf.float32,
             [None, 20, 20]),  # numpy.array is redundant
            (FEATURE_KEYS.alt1_pines, tf.float32, [None, 20, 20]),
            (FEATURE_KEYS.alt1_drone, tf.float32, [None, 20, 20]),
            (FEATURE_KEYS.alt2_drone, tf.float32, [None, 20, 20]),
            (FEATURE_KEYS.alt3_drone, tf.float32, [None, 20, 20]),
            (FEATURE_KEYS.minimap_numeric, tf.float32,
             [None, sd, sd, ObsProcesser.N_MINIMAP_CHANNELS]),
            (FEATURE_KEYS.screen_numeric, tf.float32,
             [None, sd, sd, ObsProcesser.N_SCREEN_CHANNELS]),
            (FEATURE_KEYS.screen_unit_type, tf.int32, [None, sd, sd]),
            (FEATURE_KEYS.is_spatial_action_available, tf.float32, [None]),
            # (FEATURE_KEYS.available_action_ids, tf.float32, [None, len(actions.FUNCTIONS)]),
            (FEATURE_KEYS.selected_spatial_action, tf.int32, [None, 2]),
            (FEATURE_KEYS.selected_action_id, tf.int32, [None]),
            (FEATURE_KEYS.value_target, tf.float32, [None]),
            (FEATURE_KEYS.value_target_goal, tf.float32, [None]),
            (FEATURE_KEYS.value_target_fire, tf.float32, [None]),
            (FEATURE_KEYS.rgb_screen, tf.float32,
             [nenvs, None, obs_d[0], obs_d[1],
              3]),  #[None, 32, 100, 100, 3] for LSTM
            (FEATURE_KEYS.alt_view, tf.float32,
             [nenvs, None, obs_d[0], obs_d[1],
              3]),  #[None, 32, 100, 100, 3] for LSTM
            (FEATURE_KEYS.player_relative_screen, tf.int32, [None, sd, sd]),
            (FEATURE_KEYS.player_relative_minimap, tf.int32, [None, sd, sd]),
            (FEATURE_KEYS.advantage, tf.float32, [None]),
            (FEATURE_KEYS.prev_actions, tf.int32, [None, None]),
            (FEATURE_KEYS.prev_rewards, tf.float32, [None, None]),
            (FEATURE_KEYS.altitudes, tf.int32, [None]),
            (FEATURE_KEYS.image_vol, tf.float32, [None, 5, 100, 100, 3]),
            (FEATURE_KEYS.joined, tf.float32, [None, 100, 200, 3]),
        ]
    else:
        feature_list = [
            (FEATURE_KEYS.alt0_grass, tf.float32, [None, 20, 20]),
            (FEATURE_KEYS.alt0_bush, tf.float32, [None, 20, 20]),
            # FEATURE_KEYS.available_action_ids: get_available_actions_flags(obs),
            (FEATURE_KEYS.alt0_drone, tf.float32, [None, 20, 20]),
            (FEATURE_KEYS.alt0_hiker, tf.float32, [None, 20, 20]),
            (FEATURE_KEYS.alt1_pine, tf.float32,
             [None, 20, 20]),  # numpy.array is redundant
            (FEATURE_KEYS.alt1_pines, tf.float32, [None, 20, 20]),
            (FEATURE_KEYS.alt1_drone, tf.float32, [None, 20, 20]),
            (FEATURE_KEYS.alt2_drone, tf.float32, [None, 20, 20]),
            (FEATURE_KEYS.alt3_drone, tf.float32, [None, 20, 20]),
            (FEATURE_KEYS.minimap_numeric, tf.float32,
             [None, sd, sd, ObsProcesser.N_MINIMAP_CHANNELS]),
            (FEATURE_KEYS.screen_numeric, tf.float32,
             [None, sd, sd, ObsProcesser.N_SCREEN_CHANNELS]),
            (FEATURE_KEYS.screen_unit_type, tf.int32, [None, sd, sd]),
            (FEATURE_KEYS.is_spatial_action_available, tf.float32, [None]),
            # (FEATURE_KEYS.available_action_ids, tf.float32, [None, len(actions.FUNCTIONS)]),
            (FEATURE_KEYS.selected_spatial_action, tf.int32, [None, 2]),
            (FEATURE_KEYS.selected_action_id, tf.int32, [None]),
            (FEATURE_KEYS.value_target, tf.float32, [None]),
            (FEATURE_KEYS.value_target_goal, tf.float32, [None]),
            (FEATURE_KEYS.value_target_fire, tf.float32, [None]),
            (FEATURE_KEYS.rgb_screen, tf.float32,
             [None, obs_d[0], obs_d[1], 3]),
            (FEATURE_KEYS.alt_view, tf.float32, [None, obs_d[0], obs_d[1], 3]),
            (FEATURE_KEYS.player_relative_screen, tf.int32, [None, sd, sd]),
            (FEATURE_KEYS.player_relative_minimap, tf.int32, [None, sd, sd]),
            (FEATURE_KEYS.advantage, tf.float32, [None]),
            (FEATURE_KEYS.prev_actions, tf.int32, [None, None]),
            (FEATURE_KEYS.prev_rewards, tf.float32, [None, None]),
            (FEATURE_KEYS.altitudes, tf.int32, [None]),
            (FEATURE_KEYS.image_vol, tf.float32, [None, 5, 100, 100, 3]),
            (FEATURE_KEYS.joined, tf.float32, [None, 100, 200, 3]),
        ]
    return AgentInputTuple(
        **{
            name: tf.placeholder(dtype, shape, name)
            for name, dtype, shape in feature_list
        })