neuralbench.callbacks.TestFullRetrievalMetrics¶
- class neuralbench.callbacks.TestFullRetrievalMetrics(event_type: Literal['Word', 'Image'] = 'Word', event_field: Literal['text', 'category'] = 'text', retrieval_item: Literal['trigger', 'window'] = 'trigger', window_decimals: int = 0, retrieval_set_sizes: tuple = (None, 250), save_outputs: bool = False, logger: Any = None, eval_val: bool = False)[source][source]¶
Accumulate predictions on entire test set before evaluating metrics.
Requires the pl.LightningModule object this callback is attached to to define a torch.ModuleDict named retrieval_metrics containing the metrics to evaluate.
retrieval_itemnames what one candidate of the retrieval set is:"trigger": whatever the trigger is labelled with, its text or its filepath. Repeats of a label collapse into one candidate carrying the mean of their targets, which is what a word-level or image-level retrieval score is built on."window": the file a continuous trigger (Audio,Video) plays, paired with the window’s time within that file (the trigger’soffsetplus the window’s delay from the trigger), rounded towindow_decimalsdecimals of a second. Only windows that saw the same moment of the same stimulus collapse, e.g. two subjects watching one scene. For a single event spanning the whole recording,"trigger"averages targets that differ, and the candidate it yields is a centroid rather than anything the model could have decoded.
- on_test_batch_end(trainer: Trainer, pl_module: LightningModule, outputs, batch, batch_idx, dataloader_idx=0)[source][source]¶
Called when the test batch ends.
- on_test_epoch_start(trainer: Trainer, pl_module: LightningModule)[source][source]¶
Called when the test epoch begins.
- on_validation_batch_end(trainer: Trainer, pl_module: LightningModule, outputs, batch, batch_idx, dataloader_idx=0)[source][source]¶
Called when the validation batch ends.