keras-team/keras · error · ValueError
Could not interpret metric identifier
Error message
Could not interpret metric identifier: {identifier} What it means
Raised by keras.metrics.get when the identifier cannot be resolved to any metric. The lookup accepts a config dict, a registered metric name string (e.g. 'accuracy'), or a callable/Metric instance; if the result is not callable (unknown name string or wrong type), this guard fires.
Solutions
- Use a registered metric name exactly, e.g. 'accuracy', 'auc', 'sparse_categorical_accuracy'
- Pass a Metric instance, a Metric subclass, or a callable(y_true, y_pred) -> tensor
- Register custom metrics with @keras.saving.register_keras_serializable or supply them via custom_objects
- Check the string for typos such as 'acc' variants supported in compile but not in get()
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at keras/src/metrics/__init__.py:211 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/1f2311ac51e74939.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/metrics/__init__.py:211
function or a metric class instance
Returns:
A Keras metric as a `function`/ `Metric` class instance.
"""
if identifier is None:
return None
if isinstance(identifier, dict):
obj = deserialize(identifier)
elif isinstance(identifier, str):
obj = ALL_OBJECTS_DICT.get(identifier, None)
else:
obj = identifier
if callable(obj):
if inspect.isclass(obj):
obj = obj()
return obj
else:
raise ValueError(f"Could not interpret metric identifier: {identifier}")
View on GitHub (pinned to 7a34a03db6)