PythonFunctionLambdaMap
- class tfdatacompose.lambdamap.pythonfunctionlambdamap.PythonFunctionLambdaMap(out_type: DType | Tuple[DType, ...], map: Callable[[...], Any])
Base class for inline mapping operations with arbitrary python code.
Wraps the Tensorflow Map operation on the dataset where the filter function is wrapped in py_function. The return type of the operation must be specified in advance for Tensorflow to build the computation graph. For short operations, this class can be used to avoid subclassing PythonFunctionMap. Transformations should be implemented in the
mapconstructor parameter. This operation should be used when your mapping can not be implemented in with Tensorflow operations. For example, if it needs to call an external library.- Parameters:
out_type – The return type of the operation
- apply(dataset: DatasetV1) DatasetV1
Applies the operation on the given dataset and returns the new dataset.
- Parameters:
dataset – Tensorflow Dataset The dataset to change
- Returns:
Tensorflow Dataset The changed dataset