浏览代码

added docstrings to action flattener

/develop/actionmodel-csharp
Andrew Cohen 4 年前
当前提交
662fd6b1
共有 2 个文件被更改,包括 18 次插入1 次删除
  1. 5
      ml-agents/mlagents/trainers/policy/tf_policy.py
  2. 14
      ml-agents/mlagents/trainers/torch/action_flattener.py

5
ml-agents/mlagents/trainers/policy/tf_policy.py


reparameterize,
condition_sigma_on_obs,
)
if self.behavior_spec.action_spec.continuous_size > 0 and self.behavior_spec.action_spec.discrete_size > 0:
if (
self.behavior_spec.action_spec.continuous_size > 0
and self.behavior_spec.action_spec.discrete_size > 0
):
raise UnityPolicyException(
"TensorFlow does not support mixed action spaces. Please run with the Torch framework."
)

14
ml-agents/mlagents/trainers/torch/action_flattener.py


class ActionFlattener:
def __init__(self, action_spec: ActionSpec):
"""
A torch module that creates the flattened form of an AgentAction object.
The flattened form is the continuous action concatenated with the
concatenated one hot encodings of the discrete actions.
:param action_spec: An ActionSpec that describes the action space dimensions
"""
"""
The flattened size is the continuous size plus the sum of the branch sizes
since discrete actions are encoded as one hots.
"""
"""
Returns a tensor corresponding the flattened action
:param action: An AgentAction object
"""
action_list: List[torch.Tensor] = []
if self._specs.continuous_size > 0:
action_list.append(action.continuous_tensor)

正在加载...
取消
保存