Skip to content
SR-Forge

Metric Storage

MetricEntry dataclass

Holds all variants of a single metric
  • raw: output of calculate_score (no sign, no weight)
  • best_min: True if smaller is better; False if larger is better
  • weight: optimization weight (can be 0)

MetricScores dataclass

__setitem__(name: str, entry: MetricEntry) -> None

In-place add or replace a metric. Used by hooks that inject auxiliary loss terms from on_post_forward — drop a :class:MetricEntry here and the runner's total_weighted() picks it up before backward, and LossLogger emits it as a per-name series alongside the criterion's losses.

add_scores(other: MetricScores) -> None

In-place accumulation: concatenates batch dimension when names match.