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

Method apply

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

Applies a transformation function to this dataset. `apply` enables chaining of custom `Dataset` transformations, which are represented as functions that take one `Dataset` argument and return a transformed `Dataset`. For example: ``` dataset = (dataset.map(lambda x: x ** 2

(self, transformation_func)

Source from the content-addressed store, hash-verified

1397 return FilterDataset(self, predicate)
1398
1399 def apply(self, transformation_func):
1400 """Applies a transformation function to this dataset.
1401
1402 `apply` enables chaining of custom `Dataset` transformations, which are
1403 represented as functions that take one `Dataset` argument and return a
1404 transformed `Dataset`.
1405
1406 For example:
1407
1408 ```
1409 dataset = (dataset.map(lambda x: x ** 2)
1410 .apply(group_by_window(key_func, reduce_func, window_size))
1411 .map(lambda x: x ** 3))
1412 ```
1413
1414 Args:
1415 transformation_func: A function that takes one `Dataset` argument and
1416 returns a `Dataset`.
1417
1418 Returns:
1419 Dataset: The `Dataset` returned by applying `transformation_func` to this
1420 dataset.
1421 """
1422 dataset = transformation_func(self)
1423 if not isinstance(dataset, DatasetV2):
1424 raise TypeError(
1425 "`transformation_func` must return a Dataset. Got {}.".format(
1426 dataset))
1427 dataset._input_datasets = [self] # pylint: disable=protected-access
1428 return dataset
1429
1430 def window(self, size, shift=None, stride=1, drop_remainder=False):
1431 """Combines (nests of) input elements into a dataset of (nests of) windows.

Callers 15

testOptimizationMethod · 0.45
__init__Method · 0.45
applyMethod · 0.45
_testMethod · 0.45
_testSimpleHelperMethod · 0.45
testPrefetchToDeviceMethod · 0.45

Calls 1

formatMethod · 0.45

Tested by 15

testOptimizationMethod · 0.36
_testMethod · 0.36
_testSimpleHelperMethod · 0.36
testPrefetchToDeviceMethod · 0.36
testSumMethod · 0.36