Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Add ability for Metrics to add metrics from another Metrics object #3145

Merged
merged 5 commits into from
Oct 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions parlai/core/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,16 @@ def clear(self):
def share(self):
return {'data': self._data}

def add_metrics(self, other: "Metrics") -> None:
"""
Aggregate another Metrics objects metrics into this one.

Note that it is assumed that the keys for metrics are disjoint between Metrics
objects.
"""
for k, v in other._data.items():
self.add(k, v)


class TeacherMetrics(Metrics):
"""
Expand Down