tensorflow/models · error · ValueError
Expected the row_indices tensor (output_h) has rank == 1, wa
Error message
Expected the row_indices tensor (output_h) has rank == 1, was: %s
What it means
Error "Expected the row_indices tensor (output_h) has rank == 1, was: %s" thrown in tensorflow/models.
Source
Thrown at official/vision/ops/spatial_transform_ops.py:583
Args:
input_matrix: A 2-D tensor in shape (input_h, input_w) from which to gather
values. The shape must be 2-D, since sparse matrix multiplication is
currently only supported on 2-D matrices.
row_indices: A 1-D int tensor in shape (output_h) which stored the row
indices of the input.
Returns:
A tensor in shape (output_h, input_w) which stores the gathered rows.
"""
input_matrix_shape = input_matrix.get_shape().as_list()
if len(input_matrix_shape) != 2:
raise ValueError(
'Expected the input_matrix tensor (input_h, input_w) has rank == 2, '
'was: %s' % input_matrix_shape)
row_indices_shape = row_indices.get_shape().as_list()
if len(row_indices_shape) != 1:
raise ValueError(
'Expected the row_indices tensor (output_h) has rank == 1, was: %s' %
row_indices_shape)
# (output_h, input_h)
indices_one_hot = tf.one_hot(
row_indices, depth=input_matrix_shape[0], dtype=input_matrix.dtype)
# Matrix multiplication: (output_h, input_h) x (input_h, input_w)
# (output_h, input_w)
return tf.linalg.matmul(indices_one_hot, input_matrix, a_is_sparse=True)
def bilinear_resize_to_bbox(
images: tf.Tensor, bbox: tf.Tensor, output_size: tf.Tensor
) -> 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 arbitraryView on GitHub (pinned to e006f5f0d5)
Solutions
- Pass row_indices as a rank-1 tensor of shape (output_h,).
- Flatten the row_indices tensor to 1-D.
When it happens
Trigger: Thrown at official/vision/ops/spatial_transform_ops.py:583 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/ffa490e6893f4c90.
Report an issue: GitHub.