浏览代码

Use NamedTuples instead of attrs classes

/develop/coma2/samenet
Ervin Teng 4 年前
当前提交
a6b4917a
共有 2 个文件被更改,包括 6 次插入7 次删除
  1. 3
      ml-agents/mlagents/trainers/agent_processor.py
  2. 10
      ml-agents/mlagents/trainers/trajectory.py

3
ml-agents/mlagents/trainers/agent_processor.py


experience = AgentExperience(
obs=obs,
group_status=group_statuses,
reward=step.reward,
done=done,
action=action_tuple,

interrupted=interrupted,
memory=memory,
group_status=group_statuses,
group_reward=step.group_reward,
)
# Add the value outputs if needed
self.experience_buffers[global_id].append(experience)

10
ml-agents/mlagents/trainers/trajectory.py


from typing import List, NamedTuple
import itertools
import attr
import numpy as np
from mlagents.trainers.buffer import AgentBuffer

@attr.s(auto_attribs=True)
class GroupmateStatus:
class GroupmateStatus(NamedTuple):
"""
Stores data related to an agent's teammate.
"""

done: bool
@attr.s(auto_attribs=True)
class AgentExperience:
class AgentExperience(NamedTuple):
group_status: List[GroupmateStatus]
reward: float
done: bool
action: ActionTuple

interrupted: bool
memory: np.ndarray
group_status: List[GroupmateStatus]
group_reward: float
class ObsUtil:

正在加载...
取消
保存