tfm.vision.augment.MixupAndCutmix
Stay organized with collections
Save and categorize content based on your preferences.
Applies Mixup and/or Cutmix to a batch of images.
tfm.vision.augment.MixupAndCutmix(
num_classes: int,
mixup_alpha: float = 0.8,
cutmix_alpha: float = 1.0,
prob: float = 1.0,
switch_prob: float = 0.5,
label_smoothing: float = 0.1
)
Implementaion is inspired by https://github.com/rwightman/pytorch-image-models
Args |
num_classes
|
int
Number of classes.
|
mixup_alpha
|
float, optional
For drawing a random lambda (lam ) from a
beta distribution (for each image). If zero Mixup is deactivated.
Defaults to .8.
|
cutmix_alpha
|
float, optional
For drawing a random lambda (lam ) from a
beta distribution (for each image). If zero Cutmix is deactivated.
Defaults to 1..
|
prob
|
float, optional
Of augmenting the batch. Defaults to 1.0.
|
switch_prob
|
float, optional
Probability of applying Cutmix for the
batch. Defaults to 0.5.
|
label_smoothing
|
float, optional
Constant for label smoothing. Defaults
to 0.1.
|
Methods
distort
View source
distort(
images: tf.Tensor, labels: tf.Tensor
) -> Tuple[tf.Tensor, tf.Tensor]
Applies Mixup and/or Cutmix to batch of images and transforms labels.
Args |
images
|
tf.Tensor
Of shape [batch_size, height, width, 3] representing a
batch of image, or [batch_size, time, height, width, 3] representing a
batch of video.
|
labels
|
tf.Tensor
Of shape [batch_size, ] representing the class id for
each image of the batch.
|
Returns |
Tuple[tf.Tensor, tf.Tensor]: The augmented version of image and
labels .
|
__call__
View source
__call__(
images: tf.Tensor, labels: tf.Tensor
) -> Tuple[tf.Tensor, tf.Tensor]
Call self as a function.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-02-02 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-02-02 UTC."],[],[]]