ONE - On-device Neural Engine
Loading...
Searching...
No Matches
registry.py
Go to the documentation of this file.
1
from
typing
import
Type, Dict
2
from
.metric
import
Metric
3
from
.categorical_accuracy
import
CategoricalAccuracy
4
5
6
class
MetricsRegistry
:
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]()
package.experimental.train.metrics.registry.MetricsRegistry
Definition
registry.py:6
package.experimental.train.metrics.registry.MetricsRegistry.create_metric
Metric create_metric(str name)
Definition
registry.py:15
runtime
onert
api
python
package
experimental
train
metrics
registry.py
Generated by
1.9.8