tensorflow/models · error · ValueError

For the tensor `%s`, the actual tensor rank `%d` (shape = %s

Error message

For the tensor `%s`, the actual tensor rank `%d` (shape = %s) is not equal to the expected tensor rank `%s`

What it means

Error "For the tensor `%s`, the actual tensor rank `%d` (shape = %s) is not equal to the expected tensor rank `%s`" thrown in tensorflow/models.

Source

Thrown at official/projects/detr/ops/matchers.py:444

  Args:
    tensor: A tf.Tensor to check the rank of.
    expected_rank: Python integer or list of integers, expected rank.
    name: Optional name of the tensor for the error message.

  Raises:
    ValueError: If the expected shape doesn't match the actual shape.
  """
  expected_rank_dict = {}
  if isinstance(expected_rank, int):
    expected_rank_dict[expected_rank] = True
  else:
    for x in expected_rank:
      expected_rank_dict[x] = True

  actual_rank = len(tensor.shape)
  if actual_rank not in expected_rank_dict:
    raise ValueError(
        "For the tensor `%s`, the actual tensor rank `%d` (shape = %s) is not "
        "equal to the expected tensor rank `%s`" %
        (name, actual_rank, str(tensor.shape), str(expected_rank)))


def hungarian_matching(weights):
  """Computes the minimum linear sum assignment using the Hungarian algorithm.

  Args:
    weights: A float32 [batch_size, num_elems, num_elems] tensor, where each
      inner matrix represents weights to be use for matching.

  Returns:
    A bool [batch_size, num_elems, num_elems] tensor, where each element of the
    inner matrix represents whether the worker has been matched to the job.
    The returned matching will always be a perfect match.
  """
  batch_size, num_elems, _ = tf_utils.get_shape_list(weights, 3)

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/projects/detr/ops/matchers.py:444 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/8f05bd861a057a4e. Report an issue: GitHub.