MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / flat_map

Method flat_map

tensorflow/python/data/ops/dataset_ops.py:1269–1293  ·  view source on GitHub ↗

Maps `map_func` across this dataset and flattens the result. Use `flat_map` if you want to make sure that the order of your dataset stays the same. For example, to flatten a dataset of batches into a dataset of their elements: ```python a = Dataset.from_tensor_slices([ [1, 2, 3

(self, map_func)

Source from the content-addressed store, hash-verified

1267 self, map_func, num_parallel_calls, preserve_cardinality=True)
1268
1269 def flat_map(self, map_func):
1270 """Maps `map_func` across this dataset and flattens the result.
1271
1272 Use `flat_map` if you want to make sure that the order of your dataset
1273 stays the same. For example, to flatten a dataset of batches into a
1274 dataset of their elements:
1275
1276 ```python
1277 a = Dataset.from_tensor_slices([ [1, 2, 3], [4, 5, 6], [7, 8, 9] ])
1278
1279 a.flat_map(lambda x: Dataset.from_tensor_slices(x + 1)) # ==>
1280 # [ 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
1281 ```
1282
1283 `tf.data.Dataset.interleave()` is a generalization of `flat_map`, since
1284 `flat_map` produces the same output as
1285 `tf.data.Dataset.interleave(cycle_length=1)`
1286
1287 Args:
1288 map_func: A function mapping a dataset element to a dataset.
1289
1290 Returns:
1291 Dataset: A `Dataset`.
1292 """
1293 return FlatMapDataset(self, map_func)
1294
1295 def interleave(self,
1296 map_func,

Calls 1

FlatMapDatasetClass · 0.85