attribench.functional.metrics.max_sensitivity
- attribench.functional.metrics.max_sensitivity(attributions_dataset, batch_size, method_dict, num_perturbations, radius, device=device(type='cpu'))[source]
Computes the Max-Sensitivity metric for a given Dataset and attribution methods. Max-Sensitivity is computed by adding a small amount of uniform noise to the input samples and computing the norm of the difference in attributions between the original samples and the noisy samples. The maximum norm of difference is then taken as the Max-Sensitivity.
The idea is that a small amount of noise should not change the attributions significantly, so the norm of the difference should be small. If the norm is large, then the attributions are not robust to small perturbations in the input.
- Parameters:
- attributions_datasetDataset
The dataset for which the Max-Sensitivity should be computed.
- batch_sizeint
The batch size to use for computing the Max-Sensitivity.
- method_dictDict[str, AttributionMethod]
Dictionary of attribution methods for which the Max-Sensitivity should be computed.
- num_perturbationsint
The number of perturbations to use for computing the Max-Sensitivity.
- radiusfloat
The radius of the uniform noise to add to the input samples.
- devicetorch.device, optional
Device to use, by default torch.device(“cpu”).
- Return type: