sloppy_interleave() maps map_func across dataset, and
non-deterministically interleaves the results.
The resulting dataset is almost identical to interleave. The key
difference is that if retrieving a value from a given output iterator would
cause get_next to block, that iterator will be skipped, and consumed
when next available. If consuming from all iterators would cause the
get_next call to block, the get_next call blocks until the first value is
available.
If the underlying datasets produce elements as fast as they are consumed, the
sloppy_interleave transformation behaves identically to interleave.
However, if an underlying dataset would block the consumer,
sloppy_interleave can violate the round-robin order (that interleave
strictly obeys), producing an element from a different underlying
dataset instead.
A function mapping a nested structure of tensors (having shapes
and types defined by self.output_shapes and self.output_types) 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. Note:
sloppy_interleave will skip the remainder of elements in the
block_length in order to avoid blocking.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.contrib.data.sloppy_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#L80-L132) |\n\nA non-deterministic version of the [`Dataset.interleave()`](/api_docs/python/tf/data/Dataset#interleave) transformation. (deprecated) \n\n tf.contrib.data.sloppy_interleave(\n map_func, cycle_length, block_length=1\n )\n\n| **Warning:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use [`tf.contrib.data.parallel_interleave(..., sloppy=True)`](../../../tf/contrib/data/parallel_interleave).\n\n`sloppy_interleave()` maps `map_func` across `dataset`, and\nnon-deterministically interleaves the results.\n\nThe resulting dataset is almost identical to `interleave`. The key\ndifference is that if retrieving a value from a given output iterator would\ncause `get_next` to block, that iterator will be skipped, and consumed\nwhen next available. If consuming from all iterators would cause the\n`get_next` call to block, the `get_next` call blocks until the first value is\navailable.\n\nIf the underlying datasets produce elements as fast as they are consumed, the\n`sloppy_interleave` transformation behaves identically to `interleave`.\nHowever, if an underlying dataset would block the consumer,\n`sloppy_interleave` can violate the round-robin order (that `interleave`\nstrictly obeys), producing an element from a different underlying\ndataset instead.\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.contrib.data.sloppy_interleave(\n lambda filename: tf.data.TFRecordDataset(filename),\n cycle_length=4))\n\n| **Warning:** The order of elements in the resulting dataset is not deterministic. Use [`Dataset.interleave()`](/api_docs/python/tf/data/Dataset#interleave) if you want the elements to have a deterministic order.\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 (having shapes and types defined by `self.output_shapes` and `self.output_types`) 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`. Note: `sloppy_interleave` will skip the remainder of elements in the `block_length` in order to avoid blocking. |\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"]]