tensorflow/models · error · ValueError

The length of attribute_heads should be 1 or 3, found

Error message

The length of attribute_heads should be 1 or 3, found {}

What it means

Dispatch guard in create_evaluator: the attribute head count selects a 2D evaluator (1 head, heading only) or a 3D evaluator (3 heads); any other count has no evaluator mapping and raises this ValueError.

Solutions

  1. Configure exactly 1 attribute head for 2D evaluation or 3 for 3D evaluation
  2. Align model_config.head.attribute_heads with the intended WOD evaluation mode
  3. Fix a config merge that produced an unexpected head count
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at official/projects/pointpillars/utils/wod_detection_evaluator.py:307 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/eb2ae9b19b261a00. Report an issue: GitHub.

Appendix: source

Thrown at official/projects/pointpillars/utils/wod_detection_evaluator.py:307

    values.append(box2d[:, 0])  # center_x
    values.append(box2d[:, 1])  # center_y
    values.append(box2d[:, 2])  # length
    values.append(box2d[:, 3])  # width
    values.append(attributes['heading'][:, 0])  # heading
    box2d_h = tf.stack(values, axis=-1)
    return box2d_h


def create_evaluator(model_config: cfg.PointPillarsModel) -> _AbstractEvaluator:
  """Create either 2d or 3d evaluator."""
  attr_count = len(model_config.head.attribute_heads)
  if attr_count == 1:
    logging.info('Use 2D detection evaluator.')
    return Wod2dDetectionEvaluator(model_config)
  if attr_count == 3:
    logging.info('Use 3D detection evaluator.')
    return Wod3dDetectionEvaluator(model_config)
  raise ValueError(
      'The length of attribute_heads should be 1 or 3, found {}'.format(
          attr_count))

View on GitHub (pinned to e006f5f0d5)