tensorflow/models · error · ValueError

Unknown file_type: {file_type}

Error message

Unknown file_type: {file_type}

What it means

Error "Unknown file_type: {file_type}" thrown in tensorflow/models.

Source

Thrown at official/core/file_writers.py:49

  Args:
    examples: List of tf.train.Example or tf.train.SequenceExample.
    output_path: Output path for the dataset.
    file_type: A string indicating the file format, could be: 'tfrecord',
      'tfrecords', 'tfrecord_compressed', 'tfrecords_gzip', 'riegeli'. The
      string is case insensitive.
  """
  file_type = file_type.lower()

  if file_type == 'tfrecord' or file_type == 'tfrecords':
    _write_tfrecord(examples, output_path)
  elif file_type == 'tfrecord_compressed' or file_type == 'tfrecords_gzip':
    _write_tfrecord(examples, output_path,
                    tf.io.TFRecordOptions(compression_type='GZIP'))
  elif file_type == 'riegeli':
    _write_riegeli(examples, output_path)
  else:
    raise ValueError(f'Unknown file_type: {file_type}')


def _write_tfrecord(examples: Sequence[Union[tf.train.Example,
                                             tf.train.SequenceExample]],
                    output_path: str,
                    options: Optional[tf.io.TFRecordOptions] = None) -> None:
  """Writes `examples` to a TFRecord file at `output_path`.

  Args:
    examples: A list of tf.train.Example.
    output_path: Output path for the dataset.
    options: Options used for manipulating TFRecord files.
  """
  with tf.io.TFRecordWriter(output_path, options) as writer:
    for example in examples:
      writer.write(example.SerializeToString())

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/core/file_writers.py:49 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/be5d20862723d095. Report an issue: GitHub.