浏览代码

More renaming

/MLA-1734-demo-provider
Arthur Juliani 4 年前
当前提交
986717d0
共有 5 个文件被更改,包括 17 次插入14 次删除
  1. 2
      ml-agents-envs/mlagents_envs/base_env.py
  2. 18
      ml-agents-envs/mlagents_envs/rpc_utils.py
  3. 3
      ml-agents-envs/mlagents_envs/tests/test_rpc_utils.py
  4. 4
      ml-agents-envs/mlagents_envs/tests/test_steps.py
  5. 4
      ml-agents/mlagents/trainers/tests/dummy_config.py

2
ml-agents-envs/mlagents_envs/base_env.py


"""
A NamedTuple containing information about the observation and action
spaces for a group of Agents under the same behavior.
- sensor_specs is a List of SensorSpec NamedTuple containing
- observation_specs is a List of ObservationSpec NamedTuple containing
information about the information of the Agent's observations such as their shapes.
The order of the SensorSpec is the same as the order of the observations of an
agent.

18
ml-agents-envs/mlagents_envs/rpc_utils.py


:param agent_info: protobuf object.
:return: BehaviorSpec object.
"""
sensor_specs = []
observation_specs = []
sensor_specs.append(
observation_specs.append(
SensorType(obs.sensor_type),
ObservationType(obs.sensor_type),
)
)
# proto from communicator < v1.3 does not set action spec, use deprecated fields instead

action_spec_proto.num_continuous_actions,
tuple(branch for branch in action_spec_proto.discrete_branch_sizes),
)
return BehaviorSpec(sensor_specs, action_spec)
return BehaviorSpec(observation_specs, action_spec)
class OffsetBytesIO:

]
decision_obs_list: List[np.ndarray] = []
terminal_obs_list: List[np.ndarray] = []
for obs_index, sensor_specs in enumerate(behavior_spec.observation_specs):
is_visual = len(sensor_specs.shape) == 3
for obs_index, observation_specs in enumerate(behavior_spec.observation_specs):
is_visual = len(observation_specs.shape) == 3
obs_shape = cast(Tuple[int, int, int], sensor_specs.shape)
obs_shape = cast(Tuple[int, int, int], observation_specs.shape)
decision_obs_list.append(
_process_visual_observation(
obs_index, obs_shape, decision_agent_info_list

else:
decision_obs_list.append(
_process_vector_observation(
obs_index, sensor_specs.shape, decision_agent_info_list
obs_index, observation_specs.shape, decision_agent_info_list
obs_index, sensor_specs.shape, terminal_agent_info_list
obs_index, observation_specs.shape, terminal_agent_info_list
)
)
decision_rewards = np.array(

3
ml-agents-envs/mlagents_envs/tests/test_rpc_utils.py


n_agents = 10
shapes = [(3,), (4,)]
behavior_spec = BehaviorSpec(
create_observation_specs_with_shapes(shapes), ActionSpec.create_discrete((2, 2, 6))
create_observation_specs_with_shapes(shapes),
ActionSpec.create_discrete((2, 2, 6)),
)
ap_list = generate_list_agent_proto(n_agents, shapes)
decision_steps, terminal_steps = steps_from_proto(ap_list, behavior_spec)

4
ml-agents-envs/mlagents_envs/tests/test_steps.py


def test_empty_decision_steps():
specs = BehaviorSpec(
sensor_specs=create_observation_specs_with_shapes([(3, 2), (5,)]),
observation_specs=create_observation_specs_with_shapes([(3, 2), (5,)]),
action_spec=ActionSpec.create_continuous(3),
)
ds = DecisionSteps.empty(specs)

def test_empty_terminal_steps():
specs = BehaviorSpec(
sensor_specs=create_observation_specs_with_shapes([(3, 2), (5,)]),
observation_specs=create_observation_specs_with_shapes([(3, 2), (5,)]),
action_spec=ActionSpec.create_continuous(3),
)
ts = TerminalSteps.empty(specs)

4
ml-agents/mlagents/trainers/tests/dummy_config.py


return {RewardSignalType.EXTRINSIC: RewardSignalSettings()}
def create_observation_specs_with_shapes(shapes: List[Tuple[int, ...]]) -> List[SensorSpec]:
def create_observation_specs_with_shapes(
shapes: List[Tuple[int, ...]]
) -> List[SensorSpec]:
sen_spec: List[SensorSpec] = []
for shape in shapes:
dim_prop = (DimensionProperty.UNSPECIFIED,) * len(shape)

正在加载...
取消
保存