tensorflow/models · error · ValueError
n must be 'None' or a positive integer. It was '%s'.
Error message
n must be 'None' or a positive integer. It was '%s'.
What it means
Error "n must be 'None' or a positive integer. It was '%s'." thrown in tensorflow/models.
Source
Thrown at official/projects/yt8m/eval_utils/average_precision_calculator.py:209
positive in the list. If specified, it will be used in calculation.
Returns:
The non-interpolated average precision at n.
If n is larger than the length of the ranked list,
the average precision will be returned.
Raises:
ValueError: An error occurred when
1) the format of the input is not the numpy 1-D array;
2) the shape of predictions and actuals does not match;
3) the input n is not a positive integer.
"""
if len(predictions) != len(actuals):
raise ValueError("the shape of predictions and actuals does not match.")
if n is not None:
if not isinstance(n, int) or n <= 0:
raise ValueError("n must be 'None' or a positive integer."
" It was '%s'." % n)
ap = 0.0
predictions = numpy.array(predictions)
actuals = numpy.array(actuals)
# add a shuffler to avoid overestimating the ap
predictions, actuals = AveragePrecisionCalculator._shuffle(
predictions, actuals)
sortidx = sorted(
range(len(predictions)), key=lambda k: predictions[k], reverse=True)
if total_num_positives is None:
numpos = numpy.size(numpy.where(actuals > 0))
else:
numpos = total_num_positives
View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/projects/yt8m/eval_utils/average_precision_calculator.py:209 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/fd437204af19d027.
Report an issue: GitHub.