frarch.modules.metrics.wrapper module
frarch.modules.metrics.wrapper module#
- class frarch.modules.metrics.wrapper.MetricsWrapper(**kwargs: frarch.modules.metrics.base.Metric)[source]#
Bases:
object
Store a set of metrics and perform operations in all of them simultaneously.
Example
- Sample code for metrics wrapper:
- metrics_wrapper = MetricsWrapper(
metric_str0=Metric0(), metric_str1=Metric1(),
) model = Model()
- for batch, labels in dataset:
predictions = model(batch) metrics_wrapper.update(predictions, labels)
print(metrics_wrapper.get_metrics()) # prints {“metric_str0”: 0.0, “metric_str1”: 1.0}
- __init__(**kwargs: frarch.modules.metrics.base.Metric) None [source]#
Initialize metrics in wrapper.
- Raises
ValueError – if any of the values in kwargs don’t inherit from metric.