| View source on GitHub | 
Retrieves a Keras metric as a function/Metric class instance.
tf.keras.metrics.get(
    identifier
)
  The identifier may be the string name of a metric function or class.
metric = tf.keras.metrics.get("categorical_crossentropy")
type(metric)
<class 'function'>
metric = tf.keras.metrics.get("CategoricalCrossentropy")
type(metric)
<class '...metrics.CategoricalCrossentropy'>
 You can also specify config of the metric to this function by passing dict containing class_name and config as an identifier. Also note that the class_name must map to a Metric class
identifier = {"class_name": "CategoricalCrossentropy",
              "config": {"from_logits": True} }
metric = tf.keras.metrics.get(identifier)
type(metric)
<class '...metrics.CategoricalCrossentropy'>
  
| Args | |
|---|---|
| identifier | A metric identifier. One of None or string name of a metric function/class or metric configuration dictionary or a metric function or a metric class instance | 
| Returns | |
|---|---|
| A Keras metric as a function/Metricclass instance. | 
| Raises | |
|---|---|
| ValueError | If identifiercannot be interpreted. | 
    © 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
    https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/keras/metrics/get