omniloader.transforms.base¶
Transform base classes and shared helpers.
A Transform operates on an already-unified sample dict (the output of
SampleUnifier) and is modality-agnostic — it
reasons only about vectors, sequences and their <name>_mask companions. Each
transform is:
seedable — an optional
torch.Generatormakes every draw reproducible;mask-aware — values are only altered where the mask is
True(padding and placeholders are left untouched);train/eval-aware — augmentations set
train_only = Trueso they are skipped during evaluation, while normalization runs in both phases.
Attributes¶
Classes¶
Functions¶
|
Broadcast a validity mask to the value's shape for |
|
Return explicit |
|
Return explicit |
Module Contents¶
- omniloader.transforms.base.Sample¶
- class omniloader.transforms.base.Transform[source]¶
Bases:
abc.ABCBase class for per-sample transforms.
- train_only¶
When
Truethe transform is skipped unlesstrainingis passed asTrueto__call__().
- __call__(sample: Sample, *, training: bool = True, generator: torch.Generator | None = None) Sample[source]¶
Apply the transform, honouring the train/eval gate.
- Parameters:
sample – The unified sample dict to transform.
training – Whether the pipeline is in training mode.
generator – Optional RNG for reproducible randomness.
- Returns:
The transformed sample (mutated in place and returned).
- class omniloader.transforms.base.Compose(transforms: collections.abc.Sequence[Transform])[source]¶
Bases:
TransformApply a list of transforms in order.
- Parameters:
transforms – The transforms to apply sequentially.
- omniloader.transforms.base.broadcast_mask(mask: torch.Tensor, value: torch.Tensor) torch.Tensor[source]¶
Broadcast a validity mask to the value’s shape for
torch.where.- Parameters:
mask – Mask of shape
()(vector) or(T,)(sequence).value – Value of shape
(),(F,),(T,)or(T, F).
- Returns:
A boolean tensor broadcastable to
value.shape.
- omniloader.transforms.base.resolve_keys(keys: collections.abc.Sequence[str] | None, schema: omniloader.schema.spec.UnifiedSchema | None) list[str][source]¶
Return explicit
keysor all feature keys fromschema.
- omniloader.transforms.base.resolve_sequence_keys(keys: collections.abc.Sequence[str] | None, schema: omniloader.schema.spec.UnifiedSchema | None) list[str][source]¶
Return explicit
keysor all sequence feature keys fromschema.