peal.adaptors.projection_adaptor.ProjectionAdaptor

class peal.adaptors.projection_adaptor.ProjectionAdaptor[source]

Bases: Adaptor

Training-free repair: project dictionary components out of the classifier head.

Parameters:

adaptor_config (ProjectionAdaptorConfig) – See ProjectionAdaptorConfig. base_dir is created and the sparse dictionary is built immediately.

Variables:

Methods

run

Evaluate the predictor, install the projection hook and evaluate again.

__init__(adaptor_config)[source]

Create base_dir and instantiate the sparse dictionary.

Parameters:

adaptor_config (ProjectionAdaptorConfig)

run()[source]

Evaluate the predictor, install the projection hook and evaluate again.

Loads model.cpl from base_model_config.model_path (either a pickled nn.Module or a state dict that is loaded into a freshly built ModelTrainer model), builds the dataloader of config.partition and prints overall, per-group, worst-group and average group accuracy (the latter always divides by 4). It then wraps the final linear layer (model.fc or model.model.model.fc) with projection_wrap_model and prints the same statistics again.

Returns:

Results are only printed; the hook stays registered on the in-memory model and nothing is written to disk.

Return type:

None