tensorflow/models · error · ValueError
Looping until exhausted is not supported if `options.use_tf_
Error message
Looping until exhausted is not supported if `options.use_tf_while_loop` is `True`
What it means
Error "Looping until exhausted is not supported if `options.use_tf_while_loop` is `True`" thrown in tensorflow/models.
Source
Thrown at orbit/standard_runner.py:325
return loop_fn
def evaluate(self, num_steps: tf.Tensor) -> Optional[runner.Output]:
"""Implements `num_steps` steps of evaluation.
Args:
num_steps: The number of evaluation steps to run. When this is -1,
evaluation proceeds until a call to `eval_step` raises a `StopIteration`
or `tf.errors.OutOfRangeError`.
Returns:
The output of `self.eval_end()`.
Raises:
ValueError: If `options.use_tf_while_loop` is `True` and `num_steps` is
unspecified.
"""
if self._eval_options.use_tf_while_loop and num_steps == -1:
raise ValueError("Looping until exhausted is not supported if "
"`options.use_tf_while_loop` is `True`")
outputs = self.eval_begin() # pylint: disable=assignment-from-no-return
has_state = outputs is not None
if self._eval_loop_fn is None:
self._eval_loop_fn = self.create_eval_loop_fn(has_state)
# If `recreate_iterator_for_each_eval` is `True`, `self._eval_iter` is
# always None.
if self._eval_iter is None:
eval_iter = tf.nest.map_structure(iter, self.eval_dataset)
if not self._eval_options.recreate_iterator_for_each_eval:
self._eval_iter = eval_iter
else:
eval_iter = self._eval_iter
if self._eval_options.use_tf_while_loop and not has_state:View on GitHub (pinned to e006f5f0d5)
Solutions
- Pass a finite steps count instead of -1 when use_tf_while_loop is True.
- Disable use_tf_while_loop to loop until the dataset is exhausted.
When it happens
Trigger: Thrown at orbit/standard_runner.py:325 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/e23cfab1b9ae9fde.
Report an issue: GitHub.