浏览代码

Remove some unneeded changes

/develop/coma2/samenet
Ervin Teng 4 年前
当前提交
05db051e
共有 2 个文件被更改,包括 13 次插入36 次删除
  1. 35
      ml-agents/mlagents/trainers/behavior_id_utils.py
  2. 14
      ml-agents/mlagents/trainers/ghost/trainer.py

35
ml-agents/mlagents/trainers/behavior_id_utils.py


from typing import NamedTuple, Optional
from typing import NamedTuple
from urllib.parse import urlparse, parse_qs

behavior_id: str
brain_name: str
team_id: int
group_id: int
Parses a name_behavior_id of the form name?team=0&group=0
Parses a name_behavior_id of the form name?team=0
group_id: int = 0
if "group" in ids:
group_id = int(ids["group"][0])
behavior_id=name_behavior_id,
brain_name=name,
team_id=team_id,
group_id=group_id,
behavior_id=name_behavior_id, brain_name=name, team_id=team_id
def create_name_behavior_id(
name: str, team_id: Optional[int] = None, group_id: Optional[int] = None
) -> str:
def create_name_behavior_id(name: str, team_id: int) -> str:
Reconstructs fully qualified behavior name from name and team_id
:param name: brain name
:param team_id: team ID
:return: name_behavior_id
"""
final_name = name
if team_id is not None:
final_name += f"?team={team_id}"
if group_id is not None:
final_name += f"&group={group_id}"
return final_name
Reconstructs fully qualified behavior name from name and team_id
:param name: brain name
:param team_id: team ID
:return: name_behavior_id
"""
return name + "?team=" + str(team_id)
def get_global_agent_id(worker_id: int, agent_id: int) -> str:

14
ml-agents/mlagents/trainers/ghost/trainer.py


:param parsed_behavior_id: Behavior ID that the policy should belong to.
:param policy: Policy to associate with name_behavior_id.
"""
name_behavior_id = create_name_behavior_id(
parsed_behavior_id.brain_name, team_id=parsed_behavior_id.team_id
)
# Add policy only based on the team id, not the group id
self._name_to_parsed_behavior_id[
parsed_behavior_id.behavior_id
] = parsed_behavior_id
name_behavior_id = parsed_behavior_id.behavior_id
self._name_to_parsed_behavior_id[name_behavior_id] = parsed_behavior_id
self.policies[name_behavior_id] = policy
def get_policy(self, name_behavior_id: str) -> Policy:

:return: Policy associated with name_behavior_id
"""
# Get policy based on team id, but not group id
parsed_behavior_id = BehaviorIdentifiers.from_name_behavior_id(name_behavior_id)
name_behavior_id = create_name_behavior_id(
parsed_behavior_id.brain_name, team_id=parsed_behavior_id.team_id
)
return self.policies[name_behavior_id]
def _save_snapshot(self) -> None:

正在加载...
取消
保存