View source on GitHub
|
Applies a series of layers to an input.
Inherits From: Layer, Operation
tf.keras.layers.Pipeline(
layers, name=None
)
This class is useful to build a preprocessing pipeline,
in particular an image data augmentation pipeline.
Compared to a Sequential model, Pipeline features
a few important differences:
- It's not a
Model, just a plain layer. - When the layers in the pipeline are compatible
with
tf.data, the pipeline will also remaintf.datacompatible. That is to say, the pipeline will not attempt to convert its inputs to backend-native tensors when in a tf.data context (unlike aSequentialmodel).
Example:
from keras import layers
preprocessing_pipeline = layers.Pipeline([
layers.AutoContrast(),
layers.RandomZoom(0.2),
layers.RandomRotation(0.2),
])
# `ds` is a tf.data.Dataset
preprocessed_ds = ds.map(
preprocessing_pipeline,
num_parallel_calls=4,
)
Methods
from_config
@classmethodfrom_config( config )
Creates an operation from its config.
This method is the reverse of get_config, capable of instantiating the
same operation from the config dictionary.
if "dtype" in config and isinstance(config["dtype"], dict):
policy = dtype_policies.deserialize(config["dtype"])
| Args | |
|---|---|
config
|
A Python dictionary, typically the output of get_config.
|
| Returns | |
|---|---|
| An operation instance. |
View source on GitHub