peal.explainers.counterfactual_explainer.SCEConfig¶
- class peal.explainers.counterfactual_explainer.SCEConfig[source]¶
Bases:
ExplainerConfigThis class defines the config of the SCE explainer.
Methods
Attributes
Whether to use the diversification tool that forbids changing the same area of the input image again or not.
The batch size used for the counterfactual search
The data config used for the counterfactual search
The level of dilation for the masking that is used for RePaint.
Regularizing factor that keeps changes between original image and counterfactual sparse.
The config for the predictor distillation.
The type of explanation that shall be used.
The generator that shall be used for the counterfactual search
The maximum absolute value that gradient update step can change one input variable at once.
The maximum number of gradients step done for explaining the network
Whether to only keep the best explanation while counterfactual search or not.
The threshold what is RePainted in the preexplanation.
Whether to encode every iteration again or not.
The learning rate used for finding the counterfactual
Momentum term that prevents counterfactual search from changing the area that is changed for creating the counterfactual to rapidly.
The strategy on how to merge clusters when calculating them.
Momentum term for the optimizer that does the updates of the preexplanations.
The number of discretizations when going into the latent space
The optimizer used for searching the counterfactual
The strength of the orthogonalization penalty for parallel counterfactuals.
The path to either the predictor or its config.
The path to the predictor that shall be explained.
leakyrelu, leakysoftplus This helps the distilled predictor to be more sensitive and smooth without saturating gradients.
How deep to go into the latent space for the counterfactual search
Whether to use stochastic counterfactual search (e.g. DDPM) or not (e.g. deterministic DDIM).
Whether to use a generative model to filter the gradients or not.
Whether samples in the current search batch are masked after reaching y_target_goal_confidence.
Whether to visualize gradients for every step of the counterfactual search or not.
The desired target confidence.
- generator: None | GeneratorConfig = None¶
The generator that shall be used for the counterfactual search
- data_config: None | DataConfig = None¶
The data config used for the counterfactual search
- gradient_steps: pydantic.PositiveInt = 50¶
The maximum number of gradients step done for explaining the network
- y_target_goal_confidence: None | float = None¶
The desired target confidence. Consider the tradeoff between minimality and clarity of counterfactual
- use_masking: bool = True¶
Whether samples in the current search batch are masked after reaching y_target_goal_confidence. Otherwise they are continued to be updated until the last surpasses the threshold
- dist_l1: float = 0.0¶
Regularizing factor that keeps changes between original image and counterfactual sparse.
- sampling_time_fraction: float = 0.3¶
How deep to go into the latent space for the counterfactual search
- stochastic: None | str = 'fully'¶
Whether to use stochastic counterfactual search (e.g. DDPM) or not (e.g. deterministic DDIM).
- dilation: int = 5¶
The level of dilation for the masking that is used for RePaint. If it is higher the mask is more coarse. If it is lower the mask is more finegrained.
- inpaint: float = 0.0¶
The threshold what is RePainted in the preexplanation. The repainting back to the original in the preexplanation is done for everything that has changes below 100 * inpaint percent of the maximum change between sample and preexplanation.
- replace_with_activation: str = 'leakysoftplus'¶
leakyrelu, leakysoftplus This helps the distilled predictor to be more sensitive and smooth without saturating gradients.
- Type:
The activation function ReLU is replaced with
- greedy: bool = False¶
Whether to only keep the best explanation while counterfactual search or not. While the greedy solution tends to be more stable it has bigger problems with strong local optima.
- visualize_gradients: bool = False¶
Whether to visualize gradients for every step of the counterfactual search or not. Helpful for debugging, but decreases speed and clutters disk.
- mask_momentum: float = 0.0¶
Momentum term that prevents counterfactual search from changing the area that is changed for creating the counterfactual to rapidly.
- momentum: float = 0.9¶
Momentum term for the optimizer that does the updates of the preexplanations.
- gradient_clipping: float = 0.05¶
The maximum absolute value that gradient update step can change one input variable at once.
- merge_clusters: str = 'select_best'¶
The strategy on how to merge clusters when calculating them. E.g. select_best uses the cluster that does the most salient changes, while merge just merges all clusters.
- allow_overlap: bool = False¶
Whether to use the diversification tool that forbids changing the same area of the input image again or not.