tensorflow/models · error · ValueError
Exact one metric must be present, but {0} are present.
Error message
Exact one metric must be present, but {0} are present. What it means
Error "Exact one metric must be present, but {0} are present." thrown in tensorflow/models.
Source
Thrown at official/projects/volumetric_models/tasks/semantic_segmentation_3d.py:338
def reduce_aggregated_logs(
self,
aggregated_logs: Optional[Mapping[str, Any]] = None,
global_step: Optional[tf.Tensor] = None) -> Mapping[str, float]:
"""Reduces logs to obtain per-class metrics if needed.
Args:
aggregated_logs: An optional dictionary containing aggregated logs.
global_step: An optional `tf.Tensor` of current global training steps.
Returns:
The reduced logs containing per-class metrics and overall metrics.
Raises:
ValueError: If `self.metrics` does not contain exactly 1 metric object.
"""
result = {}
if len(self.metrics) != 1:
raise ValueError('Exact one metric must be present, but {0} are '
'present.'.format(len(self.metrics)))
metric = self.metrics[0].result().numpy()
if self.task_config.evaluation.report_per_class_metric:
for i, metric_val in enumerate(metric):
metric_name = self.metrics[0].name + '/class_{0}'.format(
i - 1) if i > 0 else self.metrics[0].name
result.update({metric_name: metric_val})
else:
result.update({self.metrics[0].name: metric})
return result
View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/projects/volumetric_models/tasks/semantic_segmentation_3d.py:338 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/9e345487075538bb.
Report an issue: GitHub.