tfds.file_adapter.TFRecordExampleAdapter

Class TFRecordExampleAdapter

Writes/Reads serialized Examples protos to/from TFRecord files.

Inherits From: FileFormatAdapter

Defined in core/file_format_adapter.py.

Constraints on generators:

  • The generator must yield feature dictionaries (dict<str feature_name, feature_value>).
  • The allowed feature types are int, float, and str (or bytes in Python 3; unicode strings will be encoded in utf-8), or lists thereof.

__init__

__init__(example_reading_spec)

Constructs a TFRecordExampleAdapter.

Args:

  • example_reading_spec: dict, feature name to tf.FixedLenFeature or tf.VarLenFeature. Passed to tf.io.parse_single_example.

Properties

filetype_suffix

Methods

dataset_from_filename

dataset_from_filename(filename)

write_from_generator

write_from_generator(
    generator_fn,
    output_files
)

write_from_pcollection

write_from_pcollection(
    pcollection,
    file_path_prefix,
    num_shards
)