neuralbench.modules.DownstreamWrapperModel

class neuralbench.modules.DownstreamWrapperModel(model: Module, brain_model_output_size: Size, model_output_key: str | int | None, wrapper_n_outputs: int, preprocessor: Module | None = None, channel_adapter: Module | None = None, adapter_needs_positions: bool = False, layers_to_freeze: list[str] | None = None, layers_to_unfreeze: list[str] | Literal['last'] | None = None, strict_matching: bool = True, aggregation: Literal['flatten', 'mean', 'first'] | int | None = 'flatten', probe_config: Mlp | Literal['linear'] | None = None)[source][source]

Wrapper for downstream evaluation of pretrained models.

Handles the full pipeline: optional preprocessing -> channel adapter -> model -> output key selection -> aggregation -> probe.

forward(*args, return_embedding: bool = False, **kwargs) Tensor[source][source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.