Mixup collator (Zhang et al., 2018 — arXiv:1710.09412).
For each batch:
- Run
default_collateto get(images, labels). - One-hot encode
labelsto(B, num_classes)soft targets. - With probability
p, sample , choose a random permutation of the batch, and produce
Otherwise the batch passes through with one-hot soft targets.
Parameters
alphafloat= 0.2Beta-distribution concentration. Reference-framework
recipes use
0.2 for ImageNet, 1.0 for CIFAR.num_classesintOutput class count — required so soft targets have the right
width.
pfloat= 1.0Probability of applying Mixup per batch.
Notes
The companion loss is lucid.nn.functional.cross_entropy
with the soft target shape (B, num_classes) — Lucid's
cross_entropy accepts that natively.