neuraltrain.models.common.SubjectLayers

pydantic model neuraltrain.models.common.SubjectLayers[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.

Fields:
field n_subjects: int = 200[source]
field bias: bool = True[source]
field init_id: bool = False[source]
field mode: Literal['gather', 'for_loop'] = 'gather'[source]
field subject_dropout: float | None = None[source]
field average_subjects: bool = False[source]
build(in_channels: int, out_channels: int) Module[source][source]