{"record":{"id":"607e6dab7a4fb58c","repo":"tensorflow/models","slug":"the-shape-of-predictions-and-actuals-does-not-matc","errorCode":null,"errorMessage":"the shape of predictions and actuals does not match.","messagePattern":"the shape of predictions and actuals does not match\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/yt8m/eval_utils/average_precision_calculator.py","lineNumber":114,"sourceCode":"    After the function call, we may call peek_ap_at_n to actually calculate\n    the average precision.\n    Note predictions and actuals must have the same shape.\n\n    Args:\n      predictions: a list storing the prediction scores.\n      actuals: a list storing the ground truth labels. Any value larger than 0\n        will be treated as positives, otherwise as negatives. num_positives = If\n        the 'predictions' and 'actuals' inputs aren't complete, then it's\n        possible some true positives were missed in them. In that case, you can\n        provide 'num_positives' in order to accurately track recall.\n      num_positives: number of positive examples.\n\n    Raises:\n      ValueError: An error occurred when the format of the input is not the\n      numpy 1-D array or the shape of predictions and actuals does not match.\n    \"\"\"\n    if len(predictions) != len(actuals):\n      raise ValueError(\"the shape of predictions and actuals does not match.\")\n\n    if num_positives is not None:\n      if not isinstance(num_positives, numbers.Number) or num_positives < 0:  # pyrefly: ignore[unsupported-operation]\n        raise ValueError(\n            \"'num_positives' was provided but it was a negative number.\")\n\n    if num_positives is not None:\n      self._total_positives += num_positives\n    else:\n      self._total_positives += numpy.size(\n          numpy.where(numpy.array(actuals) > 1e-5))\n    topk = self._top_n\n    heap = self._heap\n\n    for i in range(numpy.size(predictions)):\n      if topk is None or len(heap) < topk:\n        heapq.heappush(heap, (predictions[i], actuals[i]))\n      else:","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/yt8m/eval_utils/average_precision_calculator.py#L96-L132","documentation":"Error \"the shape of predictions and actuals does not match.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/yt8m/eval_utils/average_precision_calculator.py:114 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"}