tensorflow/models · error · ValueError
Boxes shape ({boxes.shape}) and scores shape ({scores.shape}
Error message
Boxes shape ({boxes.shape}) and scores shape ({scores.shape}) do not match. What it means
Error "Boxes shape ({boxes.shape}) and scores shape ({scores.shape}) do not match." thrown in tensorflow/models.
Source
Thrown at official/vision/modeling/layers/edgetpu.py:296
scores: A 1-D+ float `Tensor` of shape `[...batch_dims, num_boxes]`
representing a single score corresponding to each box (each row of boxes).
output_size: A scalar integer `Tensor` representing the maximum number of
boxes to be selected by non-max suppression.
iou_threshold: A 0-D float tensor representing the threshold for deciding
whether boxes overlap too much with respect to IOU.
refinements: A number of extra refinement steps to make result closer to
original sequencial NMS.
Returns:
A 1-D+ integer `Tensor` of shape `[...batch_dims, output_size]` representing
the selected indices from the boxes tensor and `-1` values for the padding.
"""
boxes_size = boxes.shape[-2]
if boxes.shape[-1] != 4:
raise ValueError(f'Boxes shape ({boxes.shape}) last dimension must be 4 '
'to represent [y1, x1, y2, x2] boxes coordinates')
if scores.shape != boxes.shape[:-1]:
raise ValueError(f'Boxes shape ({boxes.shape}) and scores shape '
f'({scores.shape}) do not match.')
order = tf.constant(np.arange(boxes_size), dtype=scores.dtype)
relative_order = _tensor_sum_vectors(order, -order)
relative_scores = _tensor_sum_vectors(scores, -scores)
similar = tf.cast(
_greater(
_tensor_product_iou(boxes) -
tf.constant(iou_threshold, dtype=boxes.dtype)), scores.dtype)
worse = _greater(relative_scores)
same_later = _and(_same(relative_scores), _greater(relative_order))
similar_worse_or_same_later = _and(similar, _or(worse, same_later))
for _ in range(refinements):
similar_worse_or_same_later = _refine_nms_graph_to_original_algorithm(
similar_worse_or_same_later)
prunable = _reduce_or(similar_worse_or_same_later, axis=-1)
remaining = tf.constant(1, dtype=prunable.dtype) - prunable
if scores.shape[0] is None:
# Prefer the most of tesnor shape defined, so that error messages are clear.View on GitHub (pinned to e006f5f0d5)
Solutions
- Make boxes and scores have matching batch and box-count dimensions.
- Ensure both tensors come from the same detection outputs so their leading dimensions agree.
When it happens
Trigger: Thrown at official/vision/modeling/layers/edgetpu.py:296 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/018fef50457a48e9.
Report an issue: GitHub.