浏览代码

default ActionTuple to None

/develop/action-spec-gym
Andrew Cohen 4 年前
当前提交
930e14b9
共有 2 个文件被更改,包括 4 次插入4 次删除
  1. 4
      ml-agents-envs/mlagents_envs/base_env.py
  2. 4
      ml-agents/mlagents/trainers/env_manager.py

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


for the correct number of agents and ensures the type.
"""
_expected_shape = (n_agents, self.continuous_size)
if actions.continuous.shape != _expected_shape:
if self.continuous_size > 0 and actions.continuous.shape != _expected_shape:
raise UnityActionException(
f"The behavior {name} needs a continuous input of dimension "
f"{_expected_shape} for (<number of agents>, <action size>) but "

if actions.discrete.shape != _expected_shape:
if self.discrete_size > 0 and actions.discrete.shape != _expected_shape:
raise UnityActionException(
f"The behavior {name} needs a discrete input of dimension "
f"{_expected_shape} for (<number of agents>, <action size>) but "

4
ml-agents/mlagents/trainers/env_manager.py


@staticmethod
def action_tuple_from_numpy_dict(action_dict: Dict[str, np.ndarray]) -> ActionTuple:
continuous: np.ndarray = np.array([], dtype=np.float32)
discrete: np.ndarray = np.array([], dtype=np.int32)
continuous: np.ndarray = None
discrete: np.ndarray = None
if "continuous_action" in action_dict:
continuous = action_dict["continuous_action"]
if "discrete_action" in action_dict:
正在加载...
取消
保存