{"record":{"id":"54c59c33a98dd41d","repo":"tensorflow/models","slug":"the-number-of-anchors-inferred-from-encoded-boxes","errorCode":null,"errorMessage":"The number of anchors inferred from encoded_boxes and anchors are inconsistent: shape[1] of encoded_boxes %s should be equal to the number of anchors: %s.","messagePattern":"The number of anchors inferred from encoded_boxes and anchors are inconsistent: shape\\[1\\] of encoded_boxes (.+?) should be equal to the number of anchors: (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/utils/object_detection/box_coder.py","lineNumber":139,"sourceCode":"  Args:\n    encoded_boxes: a float32 tensor of shape [batch_size, num_anchors,\n      code_size] representing the location of the objects.\n    box_coder: a BoxCoder object.\n    anchors: a BoxList of anchors used to encode `encoded_boxes`.\n\n  Returns:\n    decoded_boxes: a float32 tensor of shape [batch_size, num_anchors,\n      coder_size] representing the corners of the objects in the order\n      of [y_min, x_min, y_max, x_max].\n\n  Raises:\n    ValueError: if batch sizes of the inputs are inconsistent, or if\n    the number of anchors inferred from encoded_boxes and anchors are\n    inconsistent.\n  \"\"\"\n  encoded_boxes.get_shape().assert_has_rank(3)\n  if encoded_boxes.get_shape()[1].value != anchors.num_boxes_static():\n    raise ValueError(\n        'The number of anchors inferred from encoded_boxes'\n        ' and anchors are inconsistent: shape[1] of encoded_boxes'\n        ' %s should be equal to the number of anchors: %s.' %\n        (encoded_boxes.get_shape()[1].value, anchors.num_boxes_static()))\n\n  decoded_boxes = tf.stack([\n      box_coder.decode(boxes, anchors).get()\n      for boxes in tf.unstack(encoded_boxes)\n  ])\n  return decoded_boxes\n","sourceCodeStart":121,"sourceCodeEnd":150,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/utils/object_detection/box_coder.py#L121-L150","documentation":"Error \"The number of anchors inferred from encoded_boxes and anchors are inconsistent: shape[1] of encoded_boxes %s should be equal to the number of anchors: %s.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/utils/object_detection/box_coder.py:139 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make encoded_boxes shape[1] equal the number of anchors.","Encode boxes against the same anchors you pass to the decoder."],"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"}