keras_cv.layers.RandAugment( value_range, augmentations_per_image=3, magnitude=0.5, magnitude_stddev=0.15, rate=0.9090909090909091, geometric=True, seed=None, **kwargs )
RandAugment performs the Rand Augment operation on input images.
This layer can be thought of as an all in one image augmentation layer. The policy implemented by this layer has been benchmarked extensively and is effective on a wide variety of datasets.
The policy operates as follows:
For each augmentation in the range
the policy selects a random operation from a list of operations.
It then samples a random number and if that number is less than
rate applies it to the given image.
[0, 255]depending on how your preprocessing pipeline is setup.
[0, 1]. A magnitude of
0indicates that the augmentations are as weak as possible (not recommended), while a value of
1.0implies use of the strongest possible augmentation. All magnitudes are clipped to the range
[0, 1]after sampling. Defaults to
[0, 1]after samples are drawn from the normal distribution. Defaults to
[0, 1]. To reproduce the original RandAugment paper results, set this to
10/11. The original
RandAugmentpaper includes an Identity transform. By setting the rate to 10/11 in our implementation, the behavior is identical to sampling an Identity augmentation 10/11th of the time. Defaults to
(x_test, y_test), _ = tf.keras.datasets.cifar10.load_data() rand_augment = keras_cv.layers.RandAugment( value_range=(0, 255), augmentations_per_image=3, magnitude=0.5 ) x_test = rand_augment(x_test)