incerto.ood.CutMix#
- class incerto.ood.CutMix(alpha=1.0)[source]#
Bases:
objectCutMix augmentation for improved robustness and OOD detection.
Instead of linearly interpolating images (mixup), cuts and pastes patches between images:
x_tilde = M ⊙ x_i + (1-M) ⊙ x_j y_tilde = λ*y_i + (1-λ)*y_j
where M is a binary mask and λ is the area ratio.
- Reference:
Yun et al. “CutMix: Regularization Strategy to Train Strong Classifiers with Localizable Features” (ICCV 2019)
- Parameters:
alpha (
float) – Beta distribution parameter (default: 1.0)
Example
>>> cutmix = CutMix(alpha=1.0) >>> mixed_x, y_a, y_b, lam = cutmix(x, y) >>> outputs = model(mixed_x) >>> loss = lam * criterion(outputs, y_a) + (1-lam) * criterion(outputs, y_b)
Methods
__init__([alpha])