holocron.utils.data

Batch collate

holocron.utils.data.Mixup(num_classes: int, alpha: float = 0.2) None[source]

Implements a batch collate function with MixUp strategy from “mixup: Beyond Empirical Risk Minimization”

Parameters:
  • num_classes – number of expected classes

  • alpha – mixup factor

>>> import torch
>>> from torch.utils.data._utils.collate import default_collate
>>> from holocron.utils.data import Mixup
>>> mix = Mixup(num_classes=10, alpha=0.4)
>>> loader = torch.utils.data.DataLoader(dataset, batch_size, collate_fn=lambda b: mix(*default_collate(b)))