tf.keras.layers.MixUp

MixUp implements the MixUp data augmentation technique.

Inherits From: Layer, Operation

alpha Float between 0 and 1. Controls the blending strength. Smaller values mean less mixing, while larger values allow for more blending between images. Defaults to 0.2, recommended for ImageNet1k classification.
seed Integer. Used to create a random seed.

Example:

(images, labels), _ = keras.datasets.cifar10.load_data()
images, labels = images[:8], labels[:8]
labels = keras.ops.cast(keras.ops.one_hot(labels.flatten(), 10), "float32")
mix_up = keras.layers.MixUp(alpha=0.2)
output = mix_up({"images": images, "labels": labels})

input Retrieves the input tensor(s) of a symbolic operation.

Only returns the tensor(s) corresponding to the first time the operation was called.

output Retrieves the output tensor(s) of a layer.

Only returns the tensor(s) corresponding to the first time the operation was called.

Methods

convert_weight

View source

Convert the weight if it is from the a different backend.

from_config

View source

Creates an operation from its config.

This method is the reverse of get_config, capable of instantiating the same operation from the config dictionary.

if "dtype" in config and isinstance(config["dtype"], dict):
    policy = dtype_policies.deserialize(config["dtype"])

Args
config A Python dictionary, typically the output of get_config.

Returns
An operation instance.

get_random_transformation

View source

transform_bounding_boxes

View source

transform_images

View source

transform_labels

View source

transform_segmentation_masks

View source

transform_single_bounding_box

View source

transform_single_image

View source

transform_single_label

View source

transform_single_segmentation_mask

View source