|View source on GitHub|
Base class for Preprocessing Layers.
Compat aliases for migration
See Migration guide for more details.
tf.keras.layers.experimental.preprocessing.PreprocessingLayer( stateful=False, streaming=True, **kwargs )
Don't use this class directly: it's an abstract base class! You may be looking for one of the many built-in preprocessing layers instead.
Preprocessing layers are layers whose state gets computed before model
training starts. They do not get updated during training.
Most preprocessing layers implement an
adapt() method for state computation.
PreprocessingLayer class is the base class you would subclass to
implement your own preprocessing layers.
Whether the layer contains state that needs to be adapted via
||Whether a layer can be adapted multiple times without resetting the state of the layer.|
||Whether the layer has been fit to data already.|
adapt( data, batch_size=None, steps=None, reset_state=True )
Fits the state of the preprocessing layer to the data being passed.
||The data to train on. It can be passed either as a tf.data Dataset, or as a numpy array.|
Optional argument specifying whether to clear the state of
the layer at the start of the call to
compile( run_eagerly=None, steps_per_execution=None )
Configures the layer for
Bool. Defaults to
Finalize the statistics for the preprocessing layer.
This method is called at the end of
adapt. This method
handles any one-time operations that should occur after all
data has been seen.
Creates a function to execute one step of
This method can be overridden to support custom adapt logic.
This method is called by
Function. The function created by this method should accept a
merge_state( layers )
Merge the statistics of multiple preprocessing layers.
This layer will contain the merged state.
||Layers whose statistics should be merge with the statistics of this layer.|
Resets the statistics of the preprocessing layer.
update_state( data )
Accumulates statistics for the preprocessing layer.
||A mini-batch of inputs to the layer.|