tensorflow/models · error · ValueError
Attribute {head.name} not found in model outputs.
Error message
Attribute {head.name} not found in model outputs. What it means
Error "Attribute {head.name} not found in model outputs." thrown in tensorflow/models.
Source
Thrown at official/vision/tasks/retinanet.py:176
box_sample_weight: tf.Tensor) -> float:
"""Computes attribute loss.
Args:
attribute_heads: a list of attribute head configs.
outputs: RetinaNet model outputs.
labels: RetinaNet labels.
box_sample_weight: normalized bounding box sample weights.
Returns:
Attribute loss of all attribute heads.
"""
params = self.task_config
attribute_loss = 0.0
for head in attribute_heads:
if head.name not in labels['attribute_targets']:
raise ValueError(f'Attribute {head.name} not found in label targets.')
if head.name not in outputs['attribute_outputs']:
raise ValueError(f'Attribute {head.name} not found in model outputs.')
if head.type == 'regression':
y_true_att = loss_utils.multi_level_flatten(
labels['attribute_targets'][head.name], last_dim=head.size
)
y_pred_att = loss_utils.multi_level_flatten(
outputs['attribute_outputs'][head.name], last_dim=head.size
)
att_loss_fn = tf_keras.losses.Huber(
1.0, reduction=tf_keras.losses.Reduction.SUM)
att_loss = att_loss_fn(
y_true=y_true_att,
y_pred=y_pred_att,
sample_weight=box_sample_weight)
elif head.type == 'classification':
y_true_att = loss_utils.multi_level_flatten(
labels['attribute_targets'][head.name], last_dim=None
)View on GitHub (pinned to e006f5f0d5)
Solutions
- Ensure the model outputs contain the attribute head's outputs keyed by head.name.
- Add the missing attribute head to the model or fix the head name in the config.
When it happens
Trigger: Thrown at official/vision/tasks/retinanet.py:176 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/101c854ac84af493.
Report an issue: GitHub.