PythonFunctionFilter

class tfdatacompose.filter.pythonfunctionfilter.PythonFunctionFilter

Base class for filtering operations with arbitrary python code.

Wraps the Tensorflow Filter operation on the dataset where the filter function is wrapped in py_function. The filtering operation should be implemented in the filter method. This operation should be used when your filtering can not be implemented in with Tensorflow operations. For instance, if it needs to call an external library.

apply(dataset: DatasetV1) DatasetV1

Applies the operation on the given dataset and returns the new dataset.

Parameters:

datasetTensorflow Dataset The dataset to change

Returns:

Tensorflow Dataset The changed dataset

abstract filter(*args) bool

Implement your filter in this method. The method receives a dataset element as Tensor and should return a boolean. The implementation of the filter can be arbitrary Python code.

Parameters:

args – the dataset element as a Tensor

Returns:

True to keep an element and False to remove it