peal.adaptors.clarc.ClArCConfig

class peal.adaptors.clarc.ClArCConfig[source]

Bases: AdaptorConfig

Configuration shared by the ClArC adaptors.

Parameters:
  • model_path (str) – torch.load-able predictor; a wrapping .model attribute is unwrapped.

  • base_dir (str) – Output directory for csv results, corrected models and logs.

  • data (DataConfig) – Training / validation data with has_confounder group labels; if data.spray_label_file is set the labels are treated as SpRAy (estimated) rather than true annotations.

  • unpoisoned_data (DataConfig, optional) – Extra clean test set evaluated as "unpoisoned-test".

  • training (TrainingConfig) – Supplies learning_rate, max_epochs and test_batch_size.

  • task (TaskConfig) – Task description handed to the dataloader factory.

  • projection_type (str, default "pcav") – CAV estimator: "pcav" (pattern CAV), "svm" (LinearSVC) or "simple" (mean difference projection, P-ClArC only).

  • layer_index (list of int, default [-1]) – Layers (indices into the flattened child list) at which to correct; 0 means the input.

  • correction_strength (list of float, default [1]) – Scaling of the projection (P-ClArC) or RR loss weight (RR-ClArC).

  • attacked_class (int, default 0) – Class whose samples are used to estimate the CAV; None uses all.

  • cav_mode (str, optional) – How conv activations are pooled before the CAV: "cavs_max", "cavs_mean" or None (flatten everything).

  • save_model (bool, default True) – Save every corrected model into base_dir.

  • max_samples (int, default 999999) – Cap on confounder / non-confounder activations collected per group.

  • reverse_cav_direction (bool, default False) – Swap the group labels before estimating the CAV.

Methods

Attributes

category: str = 'adaptor'

The category of the config. Can not be changed for adaptor. This is also necessary to identify which pydantic class to use when loading from yaml.

model_path: str
base_dir: str
data: DataConfig
unpoisoned_data: DataConfig = None
training: TrainingConfig
task: TaskConfig
projection_type: str = 'pcav'
layer_index: list[int] = [-1]
correction_strength: list[float] = [1]
attacked_class: int = 0
cav_mode: str = None
save_model: bool = True
max_samples: int = 999999
reverse_cav_direction: bool = False