ShaperMetrics
ShaperMetrics(context: RewardShapingContext, metric_namespace: str) -> NoneOwns the scalar, averaged, and per-episode metric-accumulation state for one reward shaper.
Initialize the metrics helper.
Parameters:
context(RewardShapingContext) – Shared shaping runtime context.metric_namespace(str) – The owning shaper's metric namespace.
Methods
add_averaged_metric
add_averaged_metric(name: str, value: float) -> NoneLog a shaper-specific averaged metric.
The value is buffered and written out at the step passed to the next flush.
Parameters:
name(str) – The metric name suffix.value(float) – The metric value.
add_episode_metric
add_episode_metric(name: str, env_id: int, value: float) -> NoneAccumulate a shaper-specific metric to be logged once per episode.
Parameters:
name(str) – The episode metric name suffix.env_id(int) – The environment ID.value(float) – The value to add to the episode total.
add_scalar_metric
add_scalar_metric(name: str, value: float) -> NoneLog a shaper-specific scalar metric.
The value is buffered and written out at the step passed to the next flush.
Parameters:
name(str) – The metric name suffix.value(float) – The metric value.
flush
flush(step: int) -> NoneEmit any throttled scalar and averaged metrics accumulated since the last flush.
Parameters:
step(int) – The step at which to log.
flush_episode_metrics
flush_episode_metrics(env_id: int) -> NoneEmit and clear accumulated episode metrics for one environment.
Parameters:
env_id(int) – The environment ID.
metadata_key
metadata_key(name: str) -> strBuild a namespaced learner-metadata key for this shaper.
Parameters:
name(str) – The metadata name suffix.
Returns:
str– The full metadata key.
reset_episode_metrics
reset_episode_metrics(env_id: int) -> NoneClear any accumulated episode metrics for one environment.
Parameters:
env_id(int) – The environment ID.