CutMix layer


CutMix class

keras_cv.layers.CutMix(alpha=1.0, seed=None, **kwargs)

CutMix implements the CutMix data augmentation technique.


  • alpha: Float between 0 and 1. Inverse scale parameter for the gamma distribution. This controls the shape of the distribution from which the smoothing values are sampled. Defaults 1.0, which is a recommended value when training an imagenet1k classification model.
  • seed: Integer. Used to create a random seed.


Sample usage:

(images, labels), _ = tf.keras.datasets.cifar10.load_data()
labels = tf.one_hot(labels.squeeze(), 10)

cutmix = keras_cv.layers.preprocessing.cut_mix.CutMix(10)
output = cutmix({"images": images[:32], "labels": labels[:32]})
# output == {'images': updated_images, 'labels': updated_labels}