tensorflow/models · error · ValueError
`use_tf_while_loop=True` and `use_tf_function=False` is not
Error message
`use_tf_while_loop=True` and `use_tf_function=False` is not supported
What it means
Error "`use_tf_while_loop=True` and `use_tf_function=False` is not supported" thrown in tensorflow/models.
Source
Thrown at orbit/standard_runner.py:98
Calls to `train_loop_begin` and `train_loop_end` are always done in eager
mode, while the loop/`train_step` may be implemented using `tf.while` and/or
`tf.function`, as determined by the `options` passed to `__init__`.
"""
def __init__(self,
train_dataset,
options: Optional[StandardTrainerOptions] = None):
"""Initializes the `StandardTrainer` instance.
Args:
train_dataset: A `tf.nest`-compatible structure of `tf.data.Dataset` or
`DistributedDataset`.
options: An `orbit.StandardTrainerOptions` instance.
"""
options = options or StandardTrainerOptions()
if options.use_tf_while_loop and not options.use_tf_function:
raise ValueError("`use_tf_while_loop=True` and `use_tf_function=False` "
"is not supported")
if options.use_tpu_summary_optimization and not options.use_tf_while_loop:
raise ValueError("`use_tpu_summary_optimization=True` and "
"`use_tf_while_loop=False` is not supported")
self._train_options = options
self._train_dataset = train_dataset
self._train_iter = None
self._train_loop_fn = None
def create_train_loop_fn(self):
"""Creates a training loop from the current step function and options.
Returns:
The train loop function, i.e. wrapper of multiple train steps.
"""
train_step_fn = self.train_step
if self._train_options.use_tf_while_loop:View on GitHub (pinned to e006f5f0d5)
Solutions
- Set use_tf_function=True together with use_tf_while_loop=True.
- Disable use_tf_while_loop if you must run without tf.function.
When it happens
Trigger: Thrown at orbit/standard_runner.py:98 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/a4bdecca6d457936.
Report an issue: GitHub.