BIA¶
BIA
¶
Bases: Attack
Beyond ImageNet Attack (BIA).
From the paper: Beyond ImageNet Attack: Towards Crafting Adversarial Examples for Black-box Domains.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
device
|
device | None
|
Device to use for tensors. Defaults to cuda if available. |
None
|
eps
|
float
|
The maximum perturbation. Defaults to 10/255. |
10 / 255
|
weights
|
BIAWeights | str | None
|
Pretrained weights for the generator. Either import and use the enum, or use its name. Defaults to BIAWeights.DEFAULT. |
DEFAULT
|
checkpoint_path
|
str | None
|
Path to a custom checkpoint. Defaults to None. |
None
|
clip_min
|
float
|
Minimum value for clipping. Defaults to 0.0. |
0.0
|
clip_max
|
float
|
Maximum value for clipping. Defaults to 1.0. |
1.0
|
Source code in torchattack/bia.py
forward(x, *args, **kwargs)
¶
Perform BIA on a batch of images.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
Tensor
|
A batch of images. Shape: (N, C, H, W). |
required |
Returns:
Type | Description |
---|---|
Tensor
|
The perturbed images if successful. Shape: (N, C, H, W). |
Source code in torchattack/bia.py
BIAWeights
¶
Bases: GeneratorWeightsEnum
Pretrained weights for the BIA attack generator are sourced from the original implementation of the BIA attack. RN stands for Random Normalization, and DA stands for Domain-Agnostic.
Source code in torchattack/bia.py
Available weights:
RESNET152
RESNET152_RN
RESNET152_DA
DENSENET169
DENSENET169_RN
DENSENET169_DA
VGG16
VGG16_RN
VGG16_DA
VGG19
VGG19_RN
VGG19_DA
DEFAULT