浏览代码

Add histogram aggregation type

/reward-dist
Arthur Juliani 4 年前
当前提交
9e2f0814
共有 4 个文件被更改,包括 14 次插入2 次删除
  1. 5
      com.unity.ml-agents/Runtime/StatsRecorder.cs
  2. 3
      ml-agents-envs/mlagents_envs/side_channel/stats_side_channel.py
  3. 2
      ml-agents/mlagents/trainers/stats.py
  4. 6
      ml-agents/mlagents/trainers/trainer/rl_trainer.py

5
com.unity.ml-agents/Runtime/StatsRecorder.cs


/// Values within the summary period are summed up before reporting.
/// </summary>
Sum = 2
/// <summary>
/// Values within the summary period are reported as a histogram.
/// </summary>
Histogram = 3
}
/// <summary>

3
ml-agents-envs/mlagents_envs/side_channel/stats_side_channel.py


# Values within the summary period are summed up before reporting.
SUM = 2
# All values within a summary period are reported as a histogram.
HISTOGRAM = 3
StatList = List[Tuple[float, StatsAggregationMethod]]
EnvironmentStats = Mapping[str, StatList]

2
ml-agents/mlagents/trainers/stats.py


self.summary_writers[category].add_scalar(
f"{key}", value.aggregated_value, step
)
if key == "Environment/Cumulative Reward":
if value.aggregation_method == StatsAggregationMethod.HISTOGRAM:
self.summary_writers[category].add_histogram(
f"{key}_hist", np.array(value.full_dist), step
)

6
ml-agents/mlagents/trainers/trainer/rl_trainer.py


import abc
import time
import attr
from mlagents_envs.side_channel.stats_side_channel import StatsAggregationMethod
from mlagents.trainers.policy.checkpoint_manager import (
ModelCheckpoint,
ModelCheckpointManager,

for name, rewards in self.collected_rewards.items():
if name == "environment":
self.stats_reporter.add_stat(
"Environment/Cumulative Reward", rewards.get(agent_id, 0)
"Environment/Cumulative Reward",
rewards.get(agent_id, 0),
aggregation=StatsAggregationMethod.HISTOGRAM,
)
self.cumulative_returns_since_policy_update.append(
rewards.get(agent_id, 0)

正在加载...
取消
保存