tensorflow/models · error · ValueError

Invalid total_batch_size: {}

Error message

Invalid total_batch_size: {}

What it means

Error "Invalid total_batch_size: {}" thrown in tensorflow/models.

Source

Thrown at official/vision/dataloaders/input_reader.py:108

  Args:
   total_batch_size: The total batch size for all data.
   pseudo_label_ratio: A float ratio of pseudo-labeled to labeled data in a
     batch. If it is negative, use `pseudo_label_batch_size` instead.
   pseudo_label_batch_size: The batch size of pseudo-labeled data. It is ignored
     if `pseudo_label_ratio` is valid. If not, it will be used and it cannot be
     larger than total global batch size or less than 0 if pseudo_label_ratio is
     also less than 0.

  Returns:
    (labeled_batch_size, pseudo_labeled_batch_size) as ints.

  Raises:
    ValueError: If total_batch_size is negative, or both If pseudo_label_ratio
      is negative and pseudo-label global_batch_size is negative or larger than
      total batch size.
  """
  if total_batch_size < 0:
    raise ValueError('Invalid total_batch_size: {}'.format(total_batch_size))
  if pseudo_label_ratio >= 0.0:
    ratio_factor = pseudo_label_ratio / (1.0 + pseudo_label_ratio)
    pseudo_label_batch_size = int(total_batch_size * ratio_factor)
    label_batch_size = total_batch_size - pseudo_label_batch_size
  else:
    if pseudo_label_batch_size > total_batch_size or pseudo_label_batch_size < 0:
      raise ValueError(
          'The batch size of pseudo-label dataset should not be larger than '
          'total global batch size.')
    logging.info('data_ratio for pseudo-label dataset is less than 0. '
                 'Use global_batch_size from pseudo_label data config instead.')
    label_batch_size = total_batch_size - pseudo_label_batch_size
  return label_batch_size, pseudo_label_batch_size


class CombinationDatasetInputReader(input_reader.InputReader):
  """Combination dataset input reader."""

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/vision/dataloaders/input_reader.py:108 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/b5c8520b8f099f97. Report an issue: GitHub.