{"record":{"id":"a2c48996d3c0436e","repo":"tensorflow/models","slug":"boxes-shape-boxes-shape-last-dimension-must-be","errorCode":null,"errorMessage":"Boxes shape ({boxes.shape}) last dimension must be 4 to represent [y1, x1, y2, x2] boxes coordinates","messagePattern":"Boxes shape \\((.+?)\\) last dimension must be 4 to represent \\[y1, x1, y2, x2\\] boxes coordinates","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/modeling/layers/edgetpu.py","lineNumber":293,"sourceCode":"\n  Args:\n    boxes: A 2-D+ float `Tensor` of shape `[...batch_dims, num_boxes, 4]`.\n    scores: A 1-D+ float `Tensor` of shape `[...batch_dims, num_boxes]`\n      representing a single score corresponding to each box (each row of boxes).\n    output_size: A scalar integer `Tensor` representing the maximum number of\n      boxes to be selected by non-max suppression.\n    iou_threshold: A 0-D float tensor representing the threshold for deciding\n      whether boxes overlap too much with respect to IOU.\n    refinements: A number of extra refinement steps to make result closer to\n      original sequencial NMS.\n\n  Returns:\n    A 1-D+ integer `Tensor` of shape `[...batch_dims, output_size]` representing\n    the selected indices from the boxes tensor and `-1` values for the padding.\n  \"\"\"\n  boxes_size = boxes.shape[-2]\n  if boxes.shape[-1] != 4:\n    raise ValueError(f'Boxes shape ({boxes.shape}) last dimension must be 4 '\n                     'to represent [y1, x1, y2, x2] boxes coordinates')\n  if scores.shape != boxes.shape[:-1]:\n    raise ValueError(f'Boxes shape ({boxes.shape}) and scores shape '\n                     f'({scores.shape}) do not match.')\n  order = tf.constant(np.arange(boxes_size), dtype=scores.dtype)\n  relative_order = _tensor_sum_vectors(order, -order)\n  relative_scores = _tensor_sum_vectors(scores, -scores)\n  similar = tf.cast(\n      _greater(\n          _tensor_product_iou(boxes) -\n          tf.constant(iou_threshold, dtype=boxes.dtype)), scores.dtype)\n  worse = _greater(relative_scores)\n  same_later = _and(_same(relative_scores), _greater(relative_order))\n  similar_worse_or_same_later = _and(similar, _or(worse, same_later))\n  for _ in range(refinements):\n    similar_worse_or_same_later = _refine_nms_graph_to_original_algorithm(\n        similar_worse_or_same_later)\n  prunable = _reduce_or(similar_worse_or_same_later, axis=-1)","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/modeling/layers/edgetpu.py#L275-L311","documentation":"Error \"Boxes shape ({boxes.shape}) last dimension must be 4 to represent [y1, x1, y2, x2] boxes coordinates\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/modeling/layers/edgetpu.py:293 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass boxes with last dimension 4, representing [y1, x1, y2, x2].","Fix the box tensor shape; remove any extra trailing dimensions or decode boxes correctly first."],"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"}