Configuration¶
This page describes how to configure the robustness module that probes how the model behaves under input perturbations.
Inside the robustness key, you can configure one or more named assessors.
See Examples for the config shape.
See Supported libraries for the backend behaviour behind
_target_, algorithm, and visualiser compatibility.
Options¶
Name |
Allowed |
Default |
Description |
|---|---|---|---|
|
|
|
Hydra target for the assessor class. |
|
|
Name of the underlying attack algorithm to use. The exact class is resolved by the selected assessor backend. |
|
|
|
|
Keyword arguments forwarded when constructing the assessor / underlying library object. Torchattacks consumes the perturbation budget ( |
|
|
|
Keyword arguments forwarded verbatim to the underlying library at call time. Foolbox consumes the perturbation budget ( |
|
|
|
RAITAP-owned runtime options such as batching, progress display, and sample-name metadata. These keys are not forwarded to the underlying library. |
|
|
|
Batch size for generating adversarial examples. If unset, the assessor processes the full input batch in a single call to the attack library. Set this for memory-bound attacks (Square, CW, ...) on large batches. |
|
|
|
Whether to show a progress bar across attack batches. |
|
|
|
Description used by the progress bar. |
|
|
|
Optional per-sample names for downstream visualisers. Injected at runtime from the data pipeline. Runtime sample names take precedence over |
|
|
|
Default toggle for showing sample names in visualiser titles. Set the assessor-level default here under |
|
|
|
Input modality + layout hints. Used by image visualisers to refuse non-image results and by the budget norm to size per-sample distance. Auto-inferred from |
|
|
|
Binomial CI method used by statistical-sampling assessors ( |
|
|
|
Confidence level for the binomial CI. Ignored by empirical-attack and formal-verification assessors. |
|
|
|
Visualiser definitions. Each entry must include at least |
Examples¶
robustness:
pgd:
_target_: "TorchattacksAssessor"
algorithm: "PGD"
constructor:
eps: 0.03
alpha: 0.0078
steps: 10
visualisers:
- _target_: "ImagePairVisualiser"
linf_pgd:
_target_: "FoolboxAssessor"
algorithm: "LinfPGD"
constructor:
rel_stepsize: 0.025
steps: 40
call:
eps: 0.03
visualisers:
- _target_: "ImagePairVisualiser"
- _target_: "PerturbationHeatmapVisualiser"
avg:
_target_: "ImageCorruptionsAssessor"
algorithm: "gaussian_noise" # one of the 15 ImageNet-C corruptions
constructor:
severity: 3 # 1..5
raitap:
ci_method: "wilson" # or clopper_pearson
ci_level: 0.95
visualisers:
- _target_: "CorruptionAccuracyVisualiser"
from raitap.robustness import corruption_accuracy, foolbox, image_pair, imagecorruptions, perturbation_heatmap, torchattacks
robustness = {
"pgd": torchattacks(
algorithm="PGD",
constructor={"eps": 0.03, "alpha": 0.0078, "steps": 10},
visualisers=[image_pair()],
),
"linf_pgd": foolbox(
algorithm="LinfPGD",
constructor={"rel_stepsize": 0.025, "steps": 40},
call={"eps": 0.03},
visualisers=[image_pair(), perturbation_heatmap()],
),
"avg": imagecorruptions(
algorithm="gaussian_noise",
constructor={"severity": 3},
raitap={"ci_method": "wilson", "ci_level": 0.95},
visualisers=[corruption_accuracy()],
),
}
uv run raitap +robustness=torchattacks robustness.torchattacks.algorithm=PGD robustness.torchattacks.constructor.eps=0.05
raitap +robustness=torchattacks robustness.torchattacks.algorithm=PGD robustness.torchattacks.constructor.eps=0.05