Base class for Preprocessing Layers.

Inherits From: Layer, Module

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.

The PreprocessingLayer class is the base class you would subclass to implement your own preprocessing layers.

stateful Whether the layer contains state that needs to be adapted via PreprocessingLayer.adapt.
streaming Whether a layer can be adapted multiple times without resetting the state of the layer.
is_adapted Whether the layer has been fit to data already.



View source

Fits the state of the preprocessing layer to the data being passed.

data The data to train on. It can be passed either as a Dataset, or as a numpy array.
batch_size Integer or None. Number of samples per state update. If unspecified, batch_size will default to 32. Do not specify the batch_size if your data is in the form of datasets, generators, or keras.utils.Sequence instances (since they generate batches).
steps Integer or None. Total number of steps (batches of samples) When training with input tensors such as TensorFlow data tensors, the default None is equal to the number of samples in your dataset divided by the batch size, or 1 if that cannot be determined. If x is a dataset, and 'steps' is None, the epoch will run until the input dataset is exhausted. When passing an infinitely repeating dataset, you must specify the steps argument. This argument is not supported with array inputs.
reset_state Optional argument specifying whether to clear the state of the layer at the start of the call to adapt, or whether to start from the existing state. This argument may not be relevant to all preprocessing layers: a subclass of PreprocessingLayer may choose to throw if 'reset_state' is set to False.