eegproc.deep_learning.domain_generalization.alternating_group_learning module

class eegproc.deep_learning.domain_generalization.alternating_group_learning.AlternatingSubjectSetSequence(X, y, subject_ids, subject_set_a, subject_set_b, batch_size, *, model, class_weight=None, seed=42)[source]

Bases: PyDataset

Yield batches alternately from two disjoint subject sets.

Each epoch shuffles samples independently inside both environments. Batch index parity determines the environment: even batches come from set A and odd batches from set B. The shorter environment is cycled so both sets contribute the same number of optimizer updates per epoch.

Parameters:
  • X (ndarray)

  • y (ndarray)

  • subject_ids (ndarray)

  • subject_set_a (ndarray)

  • subject_set_b (ndarray)

  • batch_size (int)

  • model (Model)

  • class_weight (dict[int, float] | None, default: None)

  • seed (int | None, default: 42)

on_epoch_end()[source]

Method called at the end of every epoch.

Return type:

None