tensorflow/models · error · ConfigError

must be a number, got .

Error message

{field_name} must be a number, got {value!r}.

What it means

A ConfigError from _require_number_in_range: the YAML value for field_name is not an int or float (booleans are explicitly rejected because bool subclasses int in Python). It fires during load_config validation for numeric thresholds like confidence values.

Solutions

  1. Replace the value with a plain number (e.g. 0.5).
  2. Quote-free unquoted strings like 'true' or 'high' are invalid; use numeric values.
  3. Note that true/false in YAML parse to booleans and are always rejected.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at official/projects/waste_identification_ml/data_generation/auto_labeler_pipeline/config_loader.py:301 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/23d559211fc474b5. Report an issue: GitHub.

Appendix: source

Thrown at official/projects/waste_identification_ml/data_generation/auto_labeler_pipeline/config_loader.py:301

  Booleans are rejected explicitly because ``bool`` is a subclass of ``int``
  in Python and would otherwise slip through numeric checks.

  Args:
      value: The value to validate.
      field_name: Field name used in the error message.
      minimum: Inclusive lower bound.
      maximum: Inclusive upper bound.
      allow_int: Whether integer values are acceptable.

  Returns:
      The validated value as a float.

  Raises:
      ConfigError: If the value is not a number or is out of range.
  """
  allowed_types = (int, float) if allow_int else (float,)
  if isinstance(value, bool) or not isinstance(value, allowed_types):
    raise ConfigError(f"{field_name} must be a number, got {value!r}.")
  if not minimum <= value <= maximum:
    raise ConfigError(
        f"{field_name} must be between {minimum} and {maximum}, "
        f"got {value!r}."
    )
  return float(value)


def _require_positive_int(value: Any, field_name: str) -> int:
  """Validates that a value is a positive (non-zero) integer.

  Args:
      value: The value to validate.
      field_name: Field name used in the error message.

  Returns:
      The validated integer.

View on GitHub (pinned to e006f5f0d5)