omniloader.transforms.mix¶
MixUp / CutMix as a collate-time wrapper.
Cross-sample mixing must happen at the batch level, so this is a collator that
wraps a base collate function rather than a per-sample Transform. It mixes
only the input feature tensors and emits the metadata a training loop needs to
compute the mixed loss itself — the paired (shuffled) targets <target>_b, the
mixing coefficient mixup_lambda and the permutation mixup_index. No loss
logic lives here, keeping the library strictly data-side.
mode="mixup"— convex blendlam * x + (1 - lam) * x[perm].mode="cutmix"— replace a contiguous time span of each sequence with the permuted sample’s span;mixup_lambdais the retained fraction.
Classes¶
Wrap a base collator to apply MixUp/CutMix to feature tensors. |
Module Contents¶
- class omniloader.transforms.mix.MixupCollator(base_collate: Any, schema: omniloader.schema.spec.UnifiedSchema, alpha: float = 0.2, mode: str = 'mixup', p: float = 1.0, seed: int = 0)[source]¶
Wrap a base collator to apply MixUp/CutMix to feature tensors.
- Parameters:
base_collate – The collator producing the batched dict (e.g.
unified_collate()orDynamicCollator).schema – The unified schema, used to pick feature/target keys.
alpha – Beta distribution parameter;
lam ~ Beta(alpha, alpha).mode –
"mixup"(blend) or"cutmix"(span replacement).p – Per-batch probability of applying mixing (otherwise passthrough).
seed – Seed for the internal NumPy RNG (deterministic across the run).
- Raises:
ValueError – If
modeis not"mixup"or"cutmix".