Skip to content

Commit

Permalink
Fix: Allow hashing of metrics with lists in their state
Browse files Browse the repository at this point in the history
  • Loading branch information
peblair committed Feb 12, 2021
1 parent 4bdf2fe commit 056b32b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pytorch_lightning/metrics/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,11 @@ def __hash__(self):
hash_vals = [self.__class__.__name__]

for key in self._defaults.keys():
hash_vals.append(getattr(self, key))
val = getattr(self, key)
# Special case: allow list values, so long as their elements are hashable
if isinstance(val, list):
val = tuple(val)
hash_vals.append(val)

return hash(tuple(hash_vals))

Expand Down

0 comments on commit 056b32b

Please sign in to comment.