Chains Keras preprocessing layers over a dictionary of features.
Every layer is addressed by its name. When the pipeline runs, a layer
reads its input from the entry that shares its name if that entry exists,
and otherwise from the output of the layer that precedes it. The result is
always written back under the layer's own name, so intermediate results
stay available to later layers and to the caller.
That single rule covers both common- shapes: * supplying one entry per layer runs the layers independently over their own inputs;
- supplying only the first layer's entry chains the layers, each one consuming what the previous layer produced.
```python
pipeline = DynamicPreprocessingPipeline(
[ScalingLayer(name="scaling"), LogLayer(name="log")]
)
# "log" is absent from the data, so it consumes the scaling output.
out = pipeline.transform({"scaling": tf.constant([[1.0], [2.0]])})
out["scaling"], out["log"]
```
__init__(self, layers: list) -> NoneInitializes the pipeline with a list of preprocessing layers.
must have a unique ``name``, which doubles as the key it reads
from and writes to.
- ValueError: If two layers share the same name.
initialize_and_transform(self, features: dict) -> dictApplies every layer to the feature dictionary.
Kept as an alias- of: meth:transform for backwards compatibility.
features (dict): Mapping of feature names to tensors.
- dict: The input entries plus one entry per layer.
process(self, dataset: tensorflow.python.data.ops.dataset_ops.DatasetV2) -> tensorflow.python.data.ops.dataset_ops.DatasetV2Processes the dataset through the pipeline using the tf.data API.
of features.
tf.data.Dataset: The processed dataset, with each layer's output
stored under the layer's name.
transform(self, features: dict) -> dictApplies every layer to the feature dictionary.
modified; a new dictionary is returned.
- dict: The input entries plus one entry per layer, holding that layer's output.
- KeyError: If a layer has no entry to read from, i.e. neither its own key nor the previous layer's output is available.