ONE - On-device Neural Engine
Loading...
Searching...
No Matches
registry.py
Go to the documentation of this file.
1from typing import Type, Dict
2from .metric import Metric
3from .categorical_accuracy import CategoricalAccuracy
4
5
7 """
8 Registry for creating metrics by name.
9 """
10 _metrics: Dict[str, Type[Metric]] = {
11 "categorical_accuracy": CategoricalAccuracy,
12 }
13
14 @staticmethod
15 def create_metric(name: str) -> Metric:
16 """
17 Create a metric instance by name.
18
19 Args:
20 name (str): Name of the metric.
21
22 Returns:
23 Metric: Metric instance.
24 """
25 if name not in MetricsRegistry._metrics:
26 raise ValueError(
27 f"Unknown Metric: {name}. Custom metric is not supported yet")
28 return MetricsRegistry._metrics[name]()