tensorflow/models · error · ValueError
Expected the input images (batch_size, height, width, ...) h
Error message
Expected the input images (batch_size, height, width, ...) has rank >= 3, was: %s
What it means
Error "Expected the input images (batch_size, height, width, ...) has rank >= 3, was: %s" thrown in tensorflow/models.
Source
Thrown at official/vision/ops/spatial_transform_ops.py:615
) -> tf.Tensor:
"""Bilinear resizes the images to fit into the bounding boxes in the output.
Args:
images: A tensor in shape (batch_size, input_h, input_w, ...) with arbitrary
numbers of channel dimensions.
bbox: A tensor in shape (batch_size, 4), representing the absolute
coordinates (ymin, xmin, ymax, xmax) for each bounding box.
output_size: The size of the output images in (output_h, output_w).
Returns:
A tensor in shape (batch_size, output_h, output_w, ...). The result has the
same dtype as the input if it's float32, float16, bfloat16, otherwise the
result is float32.
"""
images_shape = images.get_shape().as_list()
images_rank = len(images_shape)
if images_rank < 3:
raise ValueError(
'Expected the input images (batch_size, height, width, ...) '
'has rank >= 3, was: %s' % images_shape)
bbox_shape = bbox.get_shape().as_list()
if bbox_shape[-1] != 4:
raise ValueError(
'Expected the last dimension of `bbox` has size == 4, but the shape '
'of `bbox` was: %s' % bbox_shape)
rank_range = list(range(images_rank))
extra_dims = images_shape[3:]
extra_dims_perm = rank_range[3:]
extra_dims_product = 1
for d in extra_dims:
extra_dims_product *= d
input_h = tf.cast(tf.shape(images)[1], tf.float32)
input_w = tf.cast(tf.shape(images)[2], tf.float32)
output_h = output_size[0]View on GitHub (pinned to e006f5f0d5)
Solutions
- Pass input images with rank >= 3, e.g. (batch_size, height, width, ...).
- Add the missing batch/spatial dimensions to the image tensor.
When it happens
Trigger: Thrown at official/vision/ops/spatial_transform_ops.py:615 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/c799aa7188e22376.
Report an issue: GitHub.