Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sadra-barikbin committed Jul 30, 2024
1 parent 2ac34be commit 62feff2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions ignite/metrics/metric_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from typing import Any, Dict

from ignite.metrics import Metric


class MetricGroup(Metric):
def __init__(self, metrics: Dict[str, Metric]):
self.metrics = metrics
super(MetricGroup, self).__init__()

def reset(self):
for m in self.metrics.values():
m.reset()

def update(self, output):
for m in self.metrics.values():
m.update(m._output_transform(output))

def compute(self) -> Dict[str, Any]:
return {k: m.compute() for k, m in self.metrics.items()}

0 comments on commit 62feff2

Please # to comment.