{"record":{"id":"ce3a7de902c373d9","repo":"tensorflow/models","slug":"encoded-boxes-shape-1-is-d-but-must-be-4","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/legacy/detection/utils/box_utils.py","lineNumber":324,"sourceCode":"    return encoded_boxes\n\n\ndef decode_boxes(encoded_boxes, anchors, weights=None):\n  \"\"\"Decode boxes.\n\n  Args:\n    encoded_boxes: a tensor whose last dimension is 4 representing the\n      coordinates of encoded boxes in ymin, xmin, ymax, xmax 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    encoded_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('encoded_boxes.shape[-1] is {:d}, but must be 4.'.format(\n        encoded_boxes.shape[-1]))\n\n  with tf.name_scope('decode_boxes'):\n    encoded_boxes = tf.cast(encoded_boxes, dtype=anchors.dtype)\n    dy = encoded_boxes[..., 0:1]\n    dx = encoded_boxes[..., 1:2]\n    dh = encoded_boxes[..., 2:3]\n    dw = encoded_boxes[..., 3:4]\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 = anchors[..., 0:1]\n    anchor_xmin = anchors[..., 1:2]","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/legacy/detection/utils/box_utils.py#L306-L342","documentation":"Error \"encoded_boxes.shape[-1] is {:d}, but must be 4.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/legacy/detection/utils/box_utils.py:324 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"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"}