tensorflow/models · error · ValueError

Unequal shapes {}, {}

Error message

Unequal shapes {}, {}

What it means

Error "Unequal shapes {}, {}" thrown in tensorflow/models.

Source

Thrown at official/vision/utils/object_detection/shape_utils.py:43

  If the shapes are dynamic, raises a tf InvalidArgumentError when the shapes
  mismatch.

  Args:
    shape_a: a list containing shape of the first tensor.
    shape_b: a list containing shape of the second tensor.

  Returns:
    Either a tf.no_op() when shapes are all static and a tf.assert_equal() op
    when the shapes are dynamic.

  Raises:
    ValueError: When shapes are both static and unequal.
  """
  if (all(isinstance(dim, int) for dim in shape_a) and
      all(isinstance(dim, int) for dim in shape_b)):
    if shape_a != shape_b:
      raise ValueError('Unequal shapes {}, {}'.format(shape_a, shape_b))
    else:
      return tf.no_op()
  else:
    return tf.assert_equal(shape_a, shape_b)


def combined_static_and_dynamic_shape(tensor):
  """Returns a list containing static and dynamic values for the dimensions.

  Returns a list of static and dynamic values for shape dimensions. This is
  useful to preserve static shapes when available in reshape operation.

  Args:
    tensor: A tensor of any type.

  Returns:
    A list of size tensor.shape.ndims containing integers or a scalar tensor.
  """

View on GitHub (pinned to e006f5f0d5)

Solutions

  1. Make the two shapes equal before combining the tensors.
  2. Broadcast or reshape one operand so both shapes match.

When it happens

Trigger: Thrown at official/vision/utils/object_detection/shape_utils.py:43 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/71bcda804828f4d4. Report an issue: GitHub.