{"record":{"id":"d6b17acada8bb177","repo":"tensorflow/models","slug":"scores-should-have-rank-1-or-have-shape-consistent","errorCode":null,"errorMessage":"Scores should have rank 1 or have shape consistent with [None, 1]","messagePattern":"Scores should have rank 1 or have shape consistent with \\[None, 1\\]","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/utils/object_detection/box_list_ops.py","lineNumber":722,"sourceCode":"    scope: name scope.\n\n  Returns:\n    a BoxList holding M boxes where M <= N\n\n  Raises:\n    ValueError: if boxlist not a BoxList object or if it does not\n      have a scores field\n  \"\"\"\n  with tf.name_scope(scope or 'FilterGreaterThan'):\n    if not isinstance(boxlist, box_list.BoxList):\n      raise ValueError('boxlist must be a BoxList')\n    if not boxlist.has_field('scores'):\n      raise ValueError('input boxlist must have \\'scores\\' field')\n    scores = boxlist.get_field('scores')\n    if len(scores.shape.as_list()) > 2:\n      raise ValueError('Scores should have rank 1 or 2')\n    if len(scores.shape.as_list()) == 2 and scores.shape.as_list()[1] != 1:\n      raise ValueError('Scores should have rank 1 or have shape '\n                       'consistent with [None, 1]')\n    high_score_indices = tf.cast(\n        tf.reshape(tf.where(tf.greater(scores, thresh)), [-1]), tf.int32)\n    return gather(boxlist, high_score_indices)\n\n\ndef non_max_suppression(boxlist, thresh, max_output_size, scope=None):\n  \"\"\"Non maximum suppression.\n\n  This op greedily selects a subset of detection bounding boxes, pruning\n  away boxes that have high IOU (intersection over union) overlap (> thresh)\n  with already selected boxes.  Note that this only works for a single class ---\n  to apply NMS to multi-class predictions, use MultiClassNonMaxSuppression.\n\n  Args:\n    boxlist: BoxList holding N boxes.  Must contain a 'scores' field\n      representing detection scores.\n    thresh: scalar threshold","sourceCodeStart":704,"sourceCodeEnd":740,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/utils/object_detection/box_list_ops.py#L704-L740","documentation":"Error \"Scores should have rank 1 or have shape consistent with [None, 1]\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/utils/object_detection/box_list_ops.py:722 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass scores with rank 1 or shape [N, 1].","Squeeze extra dimensions from the scores tensor."],"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"}