neuraltrain.models.common.SubjectLayers¶
- class neuraltrain.models.common.SubjectLayers(*, n_subjects: int = 200, bias: bool = True, init_id: bool = False, mode: Literal['gather', 'for_loop'] = 'gather', subject_dropout: float | None = None, average_subjects: bool = False)[source][source]¶
Configuration for per-subject linear projections.
- Parameters:
n_subjects (int) – Number of subjects to allocate weight matrices for.
bias (bool) – Include a bias term in each subject’s projection.
init_id (bool) – Initialize projection matrices to the identity (requires
in_channels == out_channels).mode ({"gather", "for_loop"}) –
"gather"builds a(B, C_in, C_out)tensor via index_select (fast but memory-heavy for large channel counts)."for_loop"iterates over unique subjects (slower but lighter).subject_dropout (float or None) – Probability of replacing a subject index with a shared “dropout subject” during training. Required when average_subjects is True.
average_subjects (bool) – At inference time, use the shared dropout-subject weights for all examples. Requires subject_dropout to be set.