fast.ai callbacks to add a combination of CutMix & MixUp, or CutMix, MixUp, & Augmentation.

class CutMixUp[source]

CutMixUp(mix_alpha=0.4, cut_alpha=1.0, cutmix_ratio=1, mixup_ratio=1) :: MixUp

Combo implementation of https://arxiv.org/abs/1710.09412 and https://arxiv.org/abs/1905.04899

class CutMixUpAugment[source]

CutMixUpAugment(mix_alpha=0.4, cut_alpha=1.0, augment_ratio=1, cutmix_ratio=1, mixup_ratio=1, augs_only=None) :: MixUp

Combo implementation of https://arxiv.org/abs/1710.09412 and https://arxiv.org/abs/1905.04899 plus Augmentation

Testing

I will use the testing method from fast.ai's 19_callback.mixup.ipynb

Test CutMix

First test CutMix

cutmix = CutMixUp(cutmix_ratio=1, mixup_ratio=0)
test_cutmixup(cutmix, dls)
epoch train_loss valid_loss time
0 00:00

Then MixUp

mixup = CutMixUp(mix_alpha=1., cutmix_ratio=0, mixup_ratio=1)
test_cutmixup(mixup, dls)
epoch train_loss valid_loss time
0 00:00

Test CutMixAugment

First test CutMix

cutmix = CutMixUpAugment(cutmix_ratio=1, mixup_ratio=0, augment_ratio=0)
test_cutmixup(cutmix, dls)
epoch train_loss valid_loss time
0 00:00