braindecode.training.iter_trial_predictions#

braindecode.training.iter_trial_predictions(module, dataset, return_targets=True, batch_size=1, num_workers=0, *, loader_kwargs=None)[source]#

Yield cropped predictions, or (prediction, target) pairs, trial by trial.

Parameters:
  • module (torch.nn.Module) – Model implementing forward. It runs in eval mode without gradients; the mode of every submodule is restored on exhaustion, error or close().

  • dataset (torch.utils.data.Dataset) – Chronological cropped windows with targets and window indices.

  • return_targets (bool) – If True, yield (prediction, target) pairs.

  • batch_size (int) – DataLoader batch size.

  • num_workers (int) – DataLoader workers.

  • loader_kwargs (dict | None) – DataLoader overrides. Only batch_size, num_workers, pin_memory, persistent_workers, prefetch_factor, worker_init_fn and generator are accepted.

Yields:

prediction (np.ndarray or tuple of np.ndarray) – Float32 prediction of one trial, (n_outputs, n_predictions), or a pair with its float32 target: the first window’s target for scalar and vector targets, the overlap-reconstructed target for time targets.

Notes

Memory holds one trial, the loader batches and one window of lookahead, not the completed trials; use iter_trial_prediction_chunks() to bound a long trial. Close the iterator when stopping early. See Cropped inference: trials, chunks and lifecycle.