tensorflow/models · error · ValueError

match_results should have rank 1

Error message

match_results should have rank 1

What it means

Error "match_results should have rank 1" thrown in tensorflow/models.

Source

Thrown at official/vision/utils/object_detection/matcher.py:60

  This class is used to store the results from the matcher. It provides
  convenient methods to query the matching results.
  """

  def __init__(self, match_results):
    """Constructs a Match object.

    Args:
      match_results: Integer tensor of shape [N] with (1) match_results[i]>=0,
        meaning that column i is matched with row match_results[i]. (2)
        match_results[i]=-1, meaning that column i is not matched. (3)
        match_results[i]=-2, meaning that column i is ignored.

    Raises:
      ValueError: if match_results does not have rank 1 or is not an
        integer int32 scalar tensor
    """
    if match_results.shape.ndims != 1:
      raise ValueError('match_results should have rank 1')
    if match_results.dtype != tf.int32:
      raise ValueError('match_results should be an int32 or int64 scalar '
                       'tensor')
    self._match_results = match_results

  @property
  def match_results(self):
    """The accessor for match results.

    Returns:
      the tensor which encodes the match results.
    """
    return self._match_results

  def matched_column_indices(self):
    """Returns column indices that match to some row.

    The indices returned by this op are always sorted in increasing order.

View on GitHub (pinned to e006f5f0d5)

Solutions

  1. Pass match_results as a rank-1 tensor.
  2. Flatten the match results to shape [num_rows].

When it happens

Trigger: Thrown at official/vision/utils/object_detection/matcher.py:60 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/f6c5516cc48cdd2a. Report an issue: GitHub.