{"record":{"id":"577fa761e658afe0","repo":"tensorflow/models","slug":"encoded-boxes-shape-1-is-d-but-must-be-4-577fa7","errorCode":null,"errorMessage":"encoded_boxes.shape[-1] is {:d}, but must be 4.","messagePattern":"encoded_boxes\\.shape\\[-1\\] is (.+?), but must be 4\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/ops/box_ops.py","lineNumber":408,"sourceCode":"    return encoded_boxes\n\n\ndef decode_boxes(encoded_boxes, anchors, weights=None):\n  \"\"\"Decodes boxes.\n\n  Args:\n    encoded_boxes: a tensor whose last dimension is 4 representing the\n      coordinates of encoded boxes in dy, dx, dh, dw in order.\n    anchors: a tensor whose shape is the same as, or `broadcastable` to `boxes`,\n      representing the coordinates of anchors in ymin, xmin, ymax, xmax order.\n    weights: None or a list of four float numbers used to scale coordinates.\n\n  Returns:\n    decoded_boxes: a tensor whose shape is the same as `boxes` representing the\n      decoded box targets.\n  \"\"\"\n  if encoded_boxes.shape[-1] != 4:\n    raise ValueError(\n        'encoded_boxes.shape[-1] is {:d}, but must be 4.'\n        .format(encoded_boxes.shape[-1]))\n\n  with tf.name_scope('decode_boxes'):\n    encoded_boxes = tf.cast(encoded_boxes, dtype=anchors.dtype)\n    dy, dx, dh, dw = tf.split(encoded_boxes, 4, -1)\n    if weights:\n      dy /= weights[0]\n      dx /= weights[1]\n      dh /= weights[2]\n      dw /= weights[3]\n    dh = tf.math.minimum(dh, BBOX_XFORM_CLIP)\n    dw = tf.math.minimum(dw, BBOX_XFORM_CLIP)\n\n    anchor_ymin, anchor_xmin, anchor_ymax, anchor_xmax = tf.split(\n        anchors, 4, -1)\n    anchor_h = anchor_ymax - anchor_ymin\n    anchor_w = anchor_xmax - anchor_xmin","sourceCodeStart":390,"sourceCodeEnd":426,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/ops/box_ops.py#L390-L426","documentation":"Error \"encoded_boxes.shape[-1] is {:d}, but must be 4.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/ops/box_ops.py:408 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass encoded_boxes whose last dimension is 4.","Check the box encoding so each encoded box has exactly 4 values."],"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"}