tensorflow/models · error · ValueError
`threshold` must be sorted, got {}
Error message
`threshold` must be sorted, got {} What it means
Error "`threshold` must be sorted, got {}" thrown in tensorflow/models.
Source
Thrown at official/vision/ops/box_matcher.py:69
Args:
thresholds: A list of thresholds to classify the matches into different
types (e.g. positive or negative or ignored match). The list needs to be
sorted, and will be prepended with -Inf and appended with +Inf.
indicators: A list of values representing match types (e.g. positive or
negative or ignored match). len(`indicators`) must equal to
len(`thresholds`) + 1.
force_match_for_each_col: If True, ensures that each column is matched to
at least one row (which is not guaranteed otherwise if the
positive_threshold is high). Defaults to False. If True, all force
matched row will be assigned to `indicators[-1]`.
Raises:
ValueError: If `threshold` not sorted,
or len(indicators) != len(threshold) + 1
"""
if not all([lo <= hi for (lo, hi) in zip(thresholds[:-1], thresholds[1:])]):
raise ValueError('`threshold` must be sorted, got {}'.format(thresholds))
self.indicators = indicators
if len(indicators) != len(thresholds) + 1:
raise ValueError('len(`indicators`) must be len(`thresholds`) + 1, got '
'indicators {}, thresholds {}'.format(
indicators, thresholds))
thresholds = thresholds[:]
thresholds.insert(0, -float('inf'))
thresholds.append(float('inf'))
self.thresholds = thresholds
self._force_match_for_each_col = force_match_for_each_col
def __call__(self,
similarity_matrix: tf.Tensor) -> Tuple[tf.Tensor, tf.Tensor]:
"""Tries to match each column of the similarity matrix to a row.
Args:
similarity_matrix: A float tensor of shape [num_rows, num_cols] or
[batch_size, num_rows, num_cols] representing any similarity metric.View on GitHub (pinned to e006f5f0d5)
Solutions
- Sort the threshold list in ascending order before constructing the BoxMatcher.
- Sort your configured thresholds, e.g. thresholds=sorted(thresholds).
When it happens
Trigger: Thrown at official/vision/ops/box_matcher.py:69 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/c994706b97b0a8fe.
Report an issue: GitHub.