aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/data
diff options
context:
space:
mode:
authorGravatar Smokrow <moritz.kroeger@tu-dortmund.de>2018-09-11 17:26:16 +0200
committerGravatar GitHub <noreply@github.com>2018-09-11 17:26:16 +0200
commit9ac00398d1c0e5f3f2e76dec15fa6646f5027633 (patch)
tree1e0628dad4e7a998b23040598ded3359b56f859c /tensorflow/python/data
parentc807662d69dd1ca8bda7c34a642b812b38a4720b (diff)
Update of flat_map
Rework based on Marks review
Diffstat (limited to 'tensorflow/python/data')
-rw-r--r--tensorflow/python/data/ops/dataset_ops.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/tensorflow/python/data/ops/dataset_ops.py b/tensorflow/python/data/ops/dataset_ops.py
index 14a1e3d803..2fc41a3b98 100644
--- a/tensorflow/python/data/ops/dataset_ops.py
+++ b/tensorflow/python/data/ops/dataset_ops.py
@@ -1009,16 +1009,18 @@ class Dataset(object):
def flat_map(self, map_func):
"""Maps `map_func` across this dataset and flattens the result.
- Will produce similar results to `tf.data.Dataset.interleave(cycle_length=1)`.
+ `tf.data.Dataset.interleave()` is a generalization of `flat_map`, since
+ `flat_map` produces a similar outputs as `tf.data.Dataset.interleave(cycle_length=1)`
+
Use `flat_map` if you want to make sure, that the order of your dataset stays the same.
- For example:
+ For example, to implement unbatch:
```python
# NOTE: The following examples use `{ ... }` to represent the
# contents of a dataset. '[...]' represents a tensor.
a = {[1,2,3,4,5], [6,7,8,9], [10]}
- a.flat_map(lambda x: Dataset.from_tensors(x)) ==
+ a.flat_map(lambda x: Dataset.from_tensor_slices(x)) ==
{[1,2,3,4,5,6,7,8,9,10]}
```
Args: