tensorflow/models · error · ValueError

Invalid DType provided. Supported types

Error message

Invalid DType provided. Supported types: {}

What it means

DType property guard in DatasetBuilder: config.dtype is not one of the supported keys (float32, bfloat16, float16, fp32, bf16). A bare except converts any lookup failure — including a non-string dtype value — into this ValueError.

Solutions

  1. Set the config dtype to one of 'float32', 'bfloat16', 'float16', 'fp32', 'bf16'
  2. Check the --dtype flag spelling (e.g. use 'fp32' not 'fp-32')
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at official/legacy/image_classification/dataset_factory.py:230 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/585babe3050b3842. Report an issue: GitHub.

Appendix: source

Thrown at official/legacy/image_classification/dataset_factory.py:230

    Returns:
      A mapping from string representation of a dtype to the `tf.dtypes.DType`.

    Raises:
      ValueError if the config's dtype is not supported.

    """
    dtype_map = {
        'float32': tf.float32,
        'bfloat16': tf.bfloat16,
        'float16': tf.float16,
        'fp32': tf.float32,
        'bf16': tf.bfloat16,
    }
    try:
      return dtype_map[self.config.dtype]
    except:
      raise ValueError('Invalid DType provided. Supported types: {}'.format(
          dtype_map.keys()))

  @property
  def image_size(self) -> int:
    """The size of each image (can be inferred from the dataset)."""

    if self.config.image_size == 'infer':
      return self.info.features['image'].shape[0]
    else:
      return int(self.config.image_size)

  @property
  def num_channels(self) -> int:
    """The number of image channels (can be inferred from the dataset)."""
    if self.config.num_channels == 'infer':
      return self.info.features['image'].shape[-1]
    else:
      return int(self.config.num_channels)

View on GitHub (pinned to e006f5f0d5)