{"record":{"id":"f3f0695bb78ab3a4","repo":"tensorflow/models","slug":"expected-the-input-matrix-tensor-input-h-input-w","errorCode":null,"errorMessage":"Expected the input_matrix tensor (input_h, input_w) has rank == 2, was: %s","messagePattern":"Expected the input_matrix tensor \\(input_h, input_w\\) has rank == 2, was: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/ops/spatial_transform_ops.py","lineNumber":578,"sourceCode":"                             row_indices: tf.Tensor) -> tf.Tensor:\n  \"\"\"Gather rows from the input matrix (2-D tensor).\n\n  This operation is equivalent to tf.gather(input_matrix, row_indices), but is\n  implemented in sparse matrix multiplication.\n\n  Args:\n    input_matrix: A 2-D tensor in shape (input_h, input_w) from which to gather\n      values. The shape must be 2-D, since sparse matrix multiplication is\n      currently only supported on 2-D matrices.\n    row_indices: A 1-D int tensor in shape (output_h) which stored the row\n      indices of the input.\n\n  Returns:\n    A tensor in shape (output_h, input_w) which stores the gathered rows.\n  \"\"\"\n  input_matrix_shape = input_matrix.get_shape().as_list()\n  if len(input_matrix_shape) != 2:\n    raise ValueError(\n        'Expected the input_matrix tensor (input_h, input_w) has rank == 2, '\n        'was: %s' % input_matrix_shape)\n  row_indices_shape = row_indices.get_shape().as_list()\n  if len(row_indices_shape) != 1:\n    raise ValueError(\n        'Expected the row_indices tensor (output_h) has rank == 1, was: %s' %\n        row_indices_shape)\n\n  # (output_h, input_h)\n  indices_one_hot = tf.one_hot(\n      row_indices, depth=input_matrix_shape[0], dtype=input_matrix.dtype)\n  # Matrix multiplication: (output_h, input_h) x (input_h, input_w)\n  # (output_h, input_w)\n  return tf.linalg.matmul(indices_one_hot, input_matrix, a_is_sparse=True)\n\n\ndef bilinear_resize_to_bbox(\n    images: tf.Tensor, bbox: tf.Tensor, output_size: tf.Tensor","sourceCodeStart":560,"sourceCodeEnd":596,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/ops/spatial_transform_ops.py#L560-L596","documentation":"Error \"Expected the input_matrix tensor (input_h, input_w) has rank == 2, was: %s\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/ops/spatial_transform_ops.py:578 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass input_matrix as a rank-2 tensor of shape (input_h, input_w).","Reshape or index the matrix so it is exactly 2-D."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}