personalitylinmult.data.collate

Batching for FI samples, producing the model’s feature+mask input pairs.

The dataset already fixes every feature’s time dimension, so collation is a stack rather than a pad. What this module owns is the shape of the model call: unpack_batch() turns a batch dict into the (inputs, masks, names) triple LinMulT expects, keeping the mask contract (True = valid) in one place instead of spread through the training step.

Functions

collate_fi(→ dict[str, Any])

Collate FI samples into a batch.

unpack_batch(→ tuple[list[torch.Tensor], ...)

Split a batch into the (inputs, masks, names) LinMulT expects.

Module Contents

personalitylinmult.data.collate.collate_fi(samples: list[dict[str, Any]]) → dict[str, Any][source]

Collate FI samples into a batch.

Parameters:

samples (list[dict]) – Per-clip dicts from FiHdf5Dataset.

Returns:

Every tensor key stacked to a leading batch axis; video_id collected into a list.

Return type:

dict

Raises:

ValueError – If the batch is empty.

personalitylinmult.data.collate.unpack_batch(batch: dict[str, Any], feature_names: collections.abc.Sequence[str]) → tuple[list[torch.Tensor], list[torch.Tensor], list[str]][source]

Split a batch into the (inputs, masks, names) LinMulT expects.

Every feature is passed with its mask. LinMulT drops all-True masks internally, so a dense feature costs one .all() check and nothing more — which is why the contract stays uniform rather than special-casing which features “need” a mask.

Parameters:
  • batch (dict) – A collated batch.

  • feature_names (Sequence[str]) – Features in model input order.

Returns:

inputs of (B, T, F) (or (B, L, T, F) for a multi-layer feature), masks of (B, T) with True = valid, and the feature names, which LinMulT needs to route special handling.

Return type:

tuple

Raises:

KeyError – If a named feature or its mask is absent from the batch.