MixUp layer


MixUp class

keras_cv.layers.MixUp(alpha=0.2, seed=None, **kwargs)

MixUp implements the MixUp 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 0.2, 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()
mixup = keras_cv.layers.preprocessing.MixUp(10)
augmented_images, updated_labels = mixup({'images': images, 'labels': labels})
# output == {'images': updated_images, 'labels': updated_labels}