parallel_interleave() maps map_func across its input to produce nested
datasets, and outputs their elements interleaved. Unlike
tf.data.Dataset.interleave, it gets elements from cycle_length nested
datasets in parallel, which increases the throughput, especially in the
presence of stragglers. Furthermore, the sloppy argument can be used to
improve performance, by relaxing the requirement that the outputs are produced
in a deterministic order, and allowing the implementation to skip over nested
datasets whose elements are not readily available when requested.
A function mapping a nested structure of tensors to a Dataset.
cycle_length
The number of input Datasets to interleave from in parallel.
block_length
The number of consecutive elements to pull from an input
Dataset before advancing to the next input Dataset.
sloppy
If false, elements are produced in deterministic order. Otherwise,
the implementation is allowed, for the sake of expediency, to produce
elements in a non-deterministic order.
buffer_output_elements
The number of elements each iterator being
interleaved should buffer (similar to the .prefetch() transformation for
each interleaved iterator).
prefetch_input_elements
The number of input elements to transform to
iterators before they are needed for interleaving.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.contrib.data.parallel_interleave\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/data/python/ops/interleave_ops.py#L24-L77) |\n\nA parallel version of the [`Dataset.interleave()`](/api_docs/python/tf/data/Dataset#interleave) transformation. (deprecated) \n\n tf.contrib.data.parallel_interleave(\n map_func, cycle_length, block_length=1, sloppy=False,\n buffer_output_elements=None, prefetch_input_elements=None\n )\n\n| **Warning:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use [`tf.data.experimental.parallel_interleave(...)`](../../../tf/data/experimental/parallel_interleave).\n\n`parallel_interleave()` maps `map_func` across its input to produce nested\ndatasets, and outputs their elements interleaved. Unlike\n[`tf.data.Dataset.interleave`](../../../tf/data/Dataset#interleave), it gets elements from `cycle_length` nested\ndatasets in parallel, which increases the throughput, especially in the\npresence of stragglers. Furthermore, the `sloppy` argument can be used to\nimprove performance, by relaxing the requirement that the outputs are produced\nin a deterministic order, and allowing the implementation to skip over nested\ndatasets whose elements are not readily available when requested.\n\n#### Example usage:\n\n # Preprocess 4 files concurrently.\n filenames = tf.data.Dataset.list_files(\"/path/to/data/train*.tfrecords\")\n dataset = filenames.apply(\n tf.data.experimental.parallel_interleave(\n lambda filename: tf.data.TFRecordDataset(filename),\n cycle_length=4))\n\n| **Warning:** If `sloppy` is `True`, the order of produced elements is not deterministic.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `map_func` | A function mapping a nested structure of tensors to a `Dataset`. |\n| `cycle_length` | The number of input `Dataset`s to interleave from in parallel. |\n| `block_length` | The number of consecutive elements to pull from an input `Dataset` before advancing to the next input `Dataset`. |\n| `sloppy` | If false, elements are produced in deterministic order. Otherwise, the implementation is allowed, for the sake of expediency, to produce elements in a non-deterministic order. |\n| `buffer_output_elements` | The number of elements each iterator being interleaved should buffer (similar to the `.prefetch()` transformation for each interleaved iterator). |\n| `prefetch_input_elements` | The number of input elements to transform to iterators before they are needed for interleaving. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `Dataset` transformation function, which can be passed to [`tf.data.Dataset.apply`](../../../tf/data/Dataset#apply). ||\n\n\u003cbr /\u003e"]]