Randomly vary the width of a batch of images during training.
factor, interpolation='bilinear', seed=None, **kwargs
Adjusts the width of a batch of images by a random factor. The input
should be a 4-D tensor in the "channels_last" image data format.
By default, this layer is inactive during inference.
A positive float (fraction of original height), or a tuple of size 2
representing lower and upper bound for resizing vertically. When
represented as a single float, this value is used for both the upper and
lower bound. For instance,
factor=(0.2, 0.3) results in an output with
width changed by a random amount in the range
0.3) results in an output with width changed by a random amount in the
results in an output with width changed
by a random amount in the range[-20%, +20%]
String, the interpolation method. Defaults tobilinear
Integer. Used to create a random seed.
4D tensor with shape:
(samples, height, width, channels)
4D tensor with shape:
(samples, height, random_width, channels).
Whether the layer has been fit to data already.
adapt can be called twice without resetting the state.
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.
Number of samples per state update.
batch_size will default to 32.
Do not specify the
batch_size if your data is in the
form of datasets, generators, or
(since they generate batches).
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
tf.data 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.
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.
Configures the layer for
Bool. Defaults to
will not be wrapped in a
tf.function. Recommended to leave this as
None unless your
Model cannot be run inside a
steps_per_execution: Int. Defaults to 1. The number of batches to run
tf.function call. Running multiple batches inside a
tf.function call can greatly improve performance on TPUs or
small models with a large Python overhead.
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.