# Module: tf.data.experimental

<br />

Experimental API for building input pipelines.

This module contains experimental `Dataset` sources and transformations that can
be used in conjunction with the [`tf.data.Dataset`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/Dataset) API. Note that the
[`tf.data.experimental`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental) API is not subject to the same backwards compatibility
guarantees as [`tf.data`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data), but we will provide deprecation advice in advance of
removing existing functionality.

See [Importing Data](https://tensorflow.org/guide/datasets) for an overview.

## Modules

[`service`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/service) module: API for using the tf.data service.

## Classes

[`class AutoShardPolicy`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/AutoShardPolicy): Represents the type of auto-sharding to use.

[`class AutotuneAlgorithm`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/AutotuneAlgorithm): Represents the type of autotuning algorithm to use.

[`class AutotuneOptions`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/AutotuneOptions): Represents options for autotuning dataset performance.

[`class CheckpointInputPipelineHook`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/CheckpointInputPipelineHook): Checkpoints input pipeline state every N steps or seconds.

[`class CsvDataset`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/CsvDataset): A Dataset comprising lines from one or more CSV files.

[`class DatasetInitializer`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/DatasetInitializer): Creates a table initializer from a [`tf.data.Dataset`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/Dataset).

[`class DistributeOptions`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/DistributeOptions): Represents options for distributed data processing.

[`class ExternalStatePolicy`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/ExternalStatePolicy): Represents how to handle external state during serialization.

[`class OptimizationOptions`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/OptimizationOptions): Represents options for dataset optimizations.

[`class Optional`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/experimental/Optional): Represents a value that may or may not be present.

[`class RandomDataset`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/RandomDataset): A `Dataset` of pseudorandom values. (deprecated)

[`class Reducer`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/Reducer): A reducer is used for reducing a set of elements.

[`class SqlDataset`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/SqlDataset): A `Dataset` consisting of the results from a SQL query.

[`class TFRecordWriter`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/TFRecordWriter): Writes a dataset to a TFRecord file. (deprecated)

[`class ThreadingOptions`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/ThreadingOptions): Represents options for dataset threading.

## Functions

[`Counter(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/Counter): Creates a `Dataset` that counts from `start` in steps of size `step`. (deprecated)

[`assert_cardinality(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/assert_cardinality): Asserts the cardinality of the input dataset.

[`at(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/at): Returns the element at a specific index in a datasest.

[`bucket_by_sequence_length(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/bucket_by_sequence_length): A transformation that buckets elements in a `Dataset` by length. (deprecated)

[`cardinality(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/cardinality): Returns the cardinality of `dataset`, if known.

[`choose_from_datasets(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/choose_from_datasets): Creates a dataset that deterministically chooses elements from `datasets`. (deprecated)

[`copy_to_device(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/copy_to_device): A transformation that copies dataset elements to the given `target_device`.

[`dense_to_ragged_batch(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/dense_to_ragged_batch): A transformation that batches ragged elements into [`tf.RaggedTensor`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/RaggedTensor)s. (deprecated)

[`dense_to_sparse_batch(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/dense_to_sparse_batch): A transformation that batches ragged elements into [`tf.sparse.SparseTensor`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/sparse/SparseTensor)s. (deprecated)

[`enable_debug_mode(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/enable_debug_mode): Enables debug mode for tf.data.

[`enumerate_dataset(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/enumerate_dataset): A transformation that enumerates the elements of a dataset. (deprecated)

[`from_list(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/from_list): Creates a `Dataset` comprising the given list of elements.

[`from_variant(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/from_variant): Constructs a dataset from the given variant and (nested) structure.

[`get_next_as_optional(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/get_next_as_optional): Returns a [`tf.experimental.Optional`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/experimental/Optional) with the next element of the iterator. (deprecated)

[`get_single_element(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/get_single_element): Returns the single element of the `dataset` as a nested structure of tensors. (deprecated)

[`get_structure(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/get_structure): Returns the type signature for elements of the input dataset / iterator.

[`group_by_reducer(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/group_by_reducer): A transformation that groups elements and performs a reduction.

[`group_by_window(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/group_by_window): A transformation that groups windows of elements by key and reduces them. (deprecated)

[`ignore_errors(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/ignore_errors): Creates a `Dataset` from another `Dataset` and silently ignores any errors. (deprecated)

[`index_table_from_dataset(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/index_table_from_dataset): Returns an index lookup table based on the given dataset.

[`load(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/load): Loads a previously saved dataset. (deprecated)

[`make_batched_features_dataset(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/make_batched_features_dataset): Returns a `Dataset` of feature dictionaries from `Example` protos.

[`make_csv_dataset(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/make_csv_dataset): Reads CSV files into a dataset.

[`make_saveable_from_iterator(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/make_saveable_from_iterator): Returns a SaveableObject for saving/restoring iterator state using Saver. (deprecated)

[`map_and_batch(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/map_and_batch): Fused implementation of `map` and `batch`. (deprecated)

[`parallel_interleave(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/parallel_interleave): A parallel version of the [`Dataset.interleave()`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/Dataset#interleave) transformation. (deprecated)

[`parse_example_dataset(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/parse_example_dataset): A transformation that parses `Example` protos into a `dict` of tensors. (deprecated)

[`prefetch_to_device(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/prefetch_to_device): A transformation that prefetches dataset values to the given `device`.

[`rejection_resample(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/rejection_resample): A transformation that resamples a dataset to achieve a target distribution. (deprecated)

[`sample_from_datasets(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/sample_from_datasets): Samples elements at random from the datasets in `datasets`. (deprecated)

[`save(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/save): Saves the content of the given dataset. (deprecated)

[`scan(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/scan): A transformation that scans a function across an input dataset. (deprecated)

[`shuffle_and_repeat(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/shuffle_and_repeat): Shuffles and repeats a Dataset, reshuffling with each repetition. (deprecated)

[`snapshot(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/snapshot): API to persist the output of the input dataset. (deprecated)

[`table_from_dataset(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/table_from_dataset): Returns a lookup table based on the given dataset.

[`take_while(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/take_while): A transformation that stops dataset iteration based on a `predicate`. (deprecated)

[`to_variant(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/to_variant): Returns a variant representing the given dataset.

[`unbatch(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/unbatch): Splits elements of a dataset into multiple elements on the batch dimension. (deprecated)

[`unique(...)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/data/experimental/unique): Creates a `Dataset` from another `Dataset`, discarding duplicates. (deprecated)

<br />

<br />

<br />

| ## Other Members ||
|---|---|
| AUTOTUNE | `-1` |
| INFINITE_CARDINALITY | `-1` |
| SHARD_HINT | `-1` |
| UNKNOWN_CARDINALITY | `-2` |

<br />