BaseModel#
- class core.model.BaseModel(*args, **kwargs)[source]#
Bases:
torch.nn.modules.module.Module,abc.ABCStandardized model interface.
This class defines the recommended base interface for models using this benchmark. All models must inherit from it and implement
input_fn()andforward(), plus whichever oflink_datasets(),configure_readout()andload_ckpt()the model needs; those three default to doing nothing.create_search_space()andprocess_tunable_params()are read only when tuning with Optuna.Each suite guide shows a worked example: Task Suite 1: Behavior Prediction, Task Suite 2: Neural Activity Prediction and Pretraining.
- link_datasets(train_dataset, val_dataset, test_dataset=None)[source]#
Build whatever the model sizes from the datasets.
Called before
configure_readout(), so what is read here sizes the readout.- Parameters:
train_dataset (
IBLBrainWideBench2026) – Training split, the one to size from.val_dataset (
IBLBrainWideBench2026) – Validation split.test_dataset (
Optional[IBLBrainWideBench2026]) – Test split, or None when the run scores none.
- configure_readout(readout_spec)[source]#
Size the readout head for the task being evaluated.
Called after
link_datasets(). The spec carriesdimandnum_timesteps, so a head is sized without branching on it.- Parameters:
readout_spec (
ReadoutSpec) – SeeReadoutSpec.
- abstract input_fn(data)[source]#
Convert one trial’s data into the model’s inputs.
Runs per item on the dataloader workers, as a dataset transform, so it returns tensors rather than batches.
- Parameters:
data (
Data) – One trial, exposing the interval keyconfigure_readout()set.- Return type:
- Returns:
Dict whose
model_inputsentry is splatted intoforward(). Extra top-level keys are the model’s own to read in its trainer.
- forward(*args, **kwargs)[source]#
Run the model on one collated batch.
Takes whatever
input_fn()put undermodel_inputs, splatted in as keyword arguments, and returns what the trainer’s loss reads.
- load_ckpt(ckpt)[source]#
Copy pretrained weights out of a checkpoint into this model.
Read only the weights: the trainer restores optimizer and epoch state itself.
- Parameters:
ckpt (
dict) – The loaded checkpoint, as written by the pretraining run.
- classmethod create_search_space(trial, cfg)[source]#
Map out the model’s Optuna search space.
Call
trial.suggest_*; the names suggested become the keysprocess_tunable_params()receives.- Parameters:
trial (
Trial) – Optuna trial to register suggestions on.cfg (
DictConfig) – The run config, for values the space depends on.
- classmethod process_tunable_params(tune_params)[source]#
Turn suggested hyperparameters into config overrides.
Runs before the config is filled, so this is where a suggestion is mapped onto the config path it sets (
batch_size_log2->batch_size), a value is derived from another, or a default is supplied for something not being tuned.- Parameters:
tune_params (
dict) – The namescreate_search_space()suggested, with their values.- Return type:
- Returns:
The overrides to apply to the config. The default returns them unchanged.