# Module: tf.contrib.data

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/data/__init__.py) |

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/r1.15/api_docs/python/tf/data/Dataset) API. Note that the
[`tf.contrib.data`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/data) API is not subject to the same backwards compatibility
guarantees as [`tf.data`](https://www.tensorflow.org/versions/r1.15/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.

## Classes

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

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

[`class LMDBDataset`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/data/LMDBDataset): A LMDB Dataset that reads the lmdb file.

[`class Optional`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/data/experimental/Optional): Wraps a value that may/may not be present at runtime.

[`class RandomDataset`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/data/RandomDataset): A `Dataset` of pseudorandom values.

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

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

[`class TFRecordWriter`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/data/TFRecordWriter): Writes data to a TFRecord file.

## Functions

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

[`assert_element_shape(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/data/assert_element_shape): Assert the shape of this `Dataset`.

[`batch_and_drop_remainder(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/data/batch_and_drop_remainder): A batching transformation that omits the final small batch (if present). (deprecated)

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

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

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

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

[`enumerate_dataset(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/data/enumerate_dataset): A transformation that enumerate the elements of a dataset. (deprecated)

[`get_next_as_optional(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/data/experimental/get_next_as_optional): Returns an `Optional` that contains the next value from the iterator.

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

[`group_by_reducer(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/data/group_by_reducer): A transformation that groups elements and performs a reduction. (deprecated)

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

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

[`make_batched_features_dataset(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/data/make_batched_features_dataset): Returns a `Dataset` of feature dictionaries from `Example` protos. (deprecated)

[`make_csv_dataset(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/data/make_csv_dataset): Reads CSV files into a dataset. (deprecated)

[`make_saveable_from_iterator(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/data/make_saveable_from_iterator): Returns a SaveableObject for saving/restore iterator state using Saver. (deprecated)

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

[`padded_batch_and_drop_remainder(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/data/padded_batch_and_drop_remainder): A batching and padding transformation that omits the final small batch. (deprecated)

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

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

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

[`read_batch_features(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/data/read_batch_features): Reads batches of Examples. (deprecated)

[`reduce_dataset(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/data/reduce_dataset): Returns the result of reducing the `dataset` using `reducer`. (deprecated)

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

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

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

[`shuffle_and_repeat(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/data/shuffle_and_repeat): Shuffles and repeats a Dataset returning a new permutation for each epoch. (deprecated)

[`sliding_window_batch(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/data/sliding_window_batch): A sliding window over a dataset. (deprecated) (deprecated arguments)

[`sloppy_interleave(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/data/sloppy_interleave): A non-deterministic version of the [`Dataset.interleave()`](https://www.tensorflow.org/api_docs/python/tf/data/Dataset#interleave) transformation. (deprecated)

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

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

## Other Members

- `AUTOTUNE = -1`