Skip to content

Commit

Permalink
Add MetricDict (#533)
Browse files Browse the repository at this point in the history
* Add `MetricDict` class

* update test
  • Loading branch information
fcogidi authored Dec 13, 2023
1 parent fdee1d8 commit cbe9eeb
Show file tree
Hide file tree
Showing 5 changed files with 943 additions and 2 deletions.
1 change: 1 addition & 0 deletions cyclops/evaluate/metrics/experimental/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
MultilabelF1Score,
MultilabelFBetaScore,
)
from cyclops.evaluate.metrics.experimental.metric_dict import MetricDict
from cyclops.evaluate.metrics.experimental.precision_recall import (
BinaryPrecision,
BinaryRecall,
Expand Down
13 changes: 13 additions & 0 deletions cyclops/evaluate/metrics/experimental/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,19 @@ def __deepcopy__(self, memo: Optional[Dict[int, Any]] = None) -> "Metric":
lambda x: apc.to_device(clone(x), self.device),
)
setattr(obj_copy, k, _defaults_)
elif isinstance(v, (list, tuple)):
seq_var = apply_to_array_collection(
v,
lambda x: apc.to_device(clone(x), self.device),
)
setattr(
obj_copy,
k,
[
deepcopy(arr, memo) if not apc.is_array_api_obj(arr) else arr
for arr in seq_var
],
)
elif apc.is_array_api_obj(v):
setattr(obj_copy, k, apc.to_device(clone(v), self.device))
else:
Expand Down
Loading

0 comments on commit cbe9eeb

Please sign in to comment.