tensorflow/models · error · ValueError

steps_per_loop should be positive integer.

Error message

steps_per_loop should be positive integer.

What it means

Error "steps_per_loop should be positive integer." thrown in tensorflow/models.

Source

Thrown at official/legacy/detection/executor/distributed_executor.py:53

FLAGS = flags.FLAGS

strategy_flags_dict = hyperparams_flags.strategy_flags_dict
hparam_flags_dict = hyperparams_flags.hparam_flags_dict


def _save_checkpoint(checkpoint, model_dir, checkpoint_prefix):
  """Saves model to model_dir with provided checkpoint prefix."""

  checkpoint_path = os.path.join(model_dir, checkpoint_prefix)
  saved_path = checkpoint.save(checkpoint_path)
  logging.info('Saving model as TF checkpoint: %s', saved_path)


def _steps_to_run(current_step, total_steps, steps_per_loop):
  """Calculates steps to run on device."""
  if steps_per_loop <= 0:
    raise ValueError('steps_per_loop should be positive integer.')
  return min(total_steps - current_step, steps_per_loop)


def _no_metric():
  return None


def metrics_as_dict(metric):
  """Puts input metric(s) into a list.

  Args:
    metric: metric(s) to be put into the list. `metric` could be an object, a
      list, or a dict of tf_keras.metrics.Metric or has the `required_method`.

  Returns:
    A dictionary of valid metrics.
  """
  if isinstance(metric, tf_keras.metrics.Metric):

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/legacy/detection/executor/distributed_executor.py:53 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/eefddddd139f7781. Report an issue: GitHub.