{"record":{"id":"4605223f2a91faf7","repo":"tensorflow/models","slug":"encoded-boxes-lrtb-shape-1-is-d-but-must-be","errorCode":null,"errorMessage":"encoded_boxes_lrtb.shape[-1] is {:d}, but must be 4.","messagePattern":"encoded_boxes_lrtb\\.shape\\[-1\\] is (.+?), but must be 4\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/legacy/detection/utils/box_utils.py","lineNumber":478,"sourceCode":"def decode_boxes_lrtb(encoded_boxes_lrtb, anchors, weights=None):\n  \"\"\"Decode boxes.\n\n  Args:\n    encoded_boxes_lrtb: a tensor whose last dimension is 4 representing the\n      coordinates of encoded boxes in left, right, top, bottom 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_lrtb: a tensor whose shape is the same as `boxes` representing\n      the decoded box targets in lrtb (=left,right,top,bottom) format. The box\n      decoded box coordinates represent the left, right, top, and bottom\n      distances from an anchor location to the four borders of the matched\n      groundtruth bounding box.\n  \"\"\"\n  if encoded_boxes_lrtb.shape[-1] != 4:\n    raise ValueError(\n        'encoded_boxes_lrtb.shape[-1] is {:d}, but must be 4.'\n        .format(encoded_boxes_lrtb.shape[-1]))\n\n  with tf.name_scope('decode_boxes_lrtb'):\n    encoded_boxes_lrtb = tf.cast(encoded_boxes_lrtb, dtype=anchors.dtype)\n    left = encoded_boxes_lrtb[..., 0:1]\n    right = encoded_boxes_lrtb[..., 1:2]\n    top = encoded_boxes_lrtb[..., 2:3]\n    bottom = encoded_boxes_lrtb[..., 3:4]\n    if weights:\n      left /= weights[0]\n      right /= weights[1]\n      top /= weights[2]\n      bottom /= weights[3]\n\n    anchor_ymin = anchors[..., 0:1]\n    anchor_xmin = anchors[..., 1:2]\n    anchor_ymax = anchors[..., 2:3]","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/legacy/detection/utils/box_utils.py#L460-L496","documentation":"Error \"encoded_boxes_lrtb.shape[-1] is {:d}, but must be 4.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/legacy/detection/utils/box_utils.py:478 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"}