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

Commit

Permalink
Add ability for Metrics to add metrics from another Metrics object (#…
Browse files Browse the repository at this point in the history
…3145)

* Add notion of metrics collections, which can have other Metrics of multiple metrics be added to it

See #3138 for context and use

* right, having different arguments for the same function aren't a thing in python...

(alas, that's what I get for mostly coding in C++ for the past few years. :P)

* fixed a bug while integrating into taskmaster2

* address comments (get rid of separate class, add func to Metrics directly)

* actually do the things the last comment
  • Loading branch information
moyapchen authored Oct 2, 2020
1 parent 6b52b48 commit a04654d
Showing 1 changed file with 10 additions and 0 deletions.
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

0 comments on commit a04654d

Please sign in to comment.