Skip to content

Commit 1ecd3b5

Browse files
author
Beat Buesser
committed
Merge remote-tracking branch 'origin/main' into dev_1.11.1
2 parents fe4a1aa + e7f3b7f commit 1ecd3b5

File tree

11 files changed

+49
-47
lines changed

11 files changed

+49
-47
lines changed

.github/workflows/ci-legacy.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ jobs:
2626
matrix:
2727
module: [attacks_1, attacks_2, estimators, defences, metrics, art]
2828
include:
29-
- name: legacy (TensorFlow 2.6.0 Keras 2.6.0 PyTorch 1.10.2 scikit-learn 1.0.2 Python 3.9)
29+
- name: legacy (TensorFlow 2.6.0 Keras 2.6.0 PyTorch 1.12.0 scikit-learn 1.0.2 Python 3.9)
3030
framework: legacy
3131
python: 3.9
3232
tensorflow: 2.6.0
3333
keras: 2.6.0
34-
torch: 1.10.2+cpu
35-
torchvision: 0.11.3+cpu
36-
torchaudio: 0.10.2+cpu
34+
torch: 1.12.0+cpu
35+
torchvision: 0.13.0+cpu
36+
torchaudio: 0.12.0+cpu
3737
scikit-learn: 1.0.2
3838

3939
name: Run ${{ matrix.module }} ${{ matrix.name }} Tests

.github/workflows/ci-pytorch-object-detectors.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ jobs:
4040
pip list
4141
- name: Pre-install torch
4242
run: |
43-
pip install torch==1.10.2+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html
44-
pip install torchvision==0.11.3+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html
45-
pip install torchaudio==0.10.2+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html
43+
pip install torch==1.12.0+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html
44+
pip install torchvision==0.13.0+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html
45+
pip install torchaudio==0.12.0+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html
4646
- name: Run Test Action - test_pytorch_object_detector
4747
run: pytest --cov-report=xml --cov=art --cov-append -q -vv tests/estimators/object_detection/test_pytorch_object_detector.py --framework=pytorch --durations=0
4848
- name: Run Test Action - test_pytorch_faster_rcnn

.github/workflows/ci-pytorch.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ jobs:
2525
fail-fast: false
2626
matrix:
2727
include:
28-
- name: PyTorch 1.9.1 (Python 3.8)
29-
framework: pytorch
30-
python: 3.8
31-
torch: 1.9.1+cpu
32-
torchvision: 0.10.1+cpu
33-
torchaudio: 0.9.1
3428
- name: PyTorch 1.10.2 (Python 3.8)
3529
framework: pytorch
3630
python: 3.8
@@ -43,6 +37,12 @@ jobs:
4337
torch: 1.11.0+cpu
4438
torchvision: 0.12.0+cpu
4539
torchaudio: 0.11.0
40+
- name: PyTorch 1.12.0 (Python 3.8)
41+
framework: pytorch
42+
python: 3.8
43+
torch: 1.12.0+cpu
44+
torchvision: 0.13.0+cpu
45+
torchaudio: 0.12.0
4646

4747
name: ${{ matrix.name }}
4848
steps:

art/attacks/evasion/sign_opt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ def __init__(
110110
:param epsilon: A very small smoothing parameter.
111111
:param num_trial: A number of trials to calculate a good starting point
112112
:param max_iter: Maximum number of iterations.
113-
Default value is for untargeted attack, increase to recommended 5000 for targeted attacks.
113+
Default value is for untargeted attack, increase to recommended 5000 for targeted attacks.
114114
:param query_limit: Limitation for number of queries to prediction model.
115-
Default value is for untargeted attack, increase to recommended 40000 for targeted attacks.
115+
Default value is for untargeted attack, increase to recommended 40000 for targeted attacks.
116116
:param k: Number of random directions (for estimating the gradient)
117117
:param alpha: The step length for line search
118118
:param beta: The tolerance for line search

art/attacks/inference/membership_inference/shadow_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def generate_shadow_dataset(
7171
the dataset into training and testing samples, and then training the shadow models on the result.
7272
7373
:param x: The samples used to train the shadow models.
74-
:param y: True labels for the dataset samples.
74+
:param y: True labels for the dataset samples (as expected by the estimator's fit method).
7575
:param member_ratio: Percentage of the data that should be used to train the shadow models. Must be between 0
7676
and 1.
7777

art/estimators/certification/deep_z/pytorch.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@
3838

3939
class PytorchDeepZ(PyTorchClassifier, ZonoBounds):
4040
"""
41-
Implementation of DeepZ to certify neural network robustness.
42-
43-
We use the zonotope representation of a datapoint as it travels through the network to then verify if it can
44-
have its class changed given a certain perturbation.
41+
Implementation of DeepZ to certify neural network robustness. We use the zonotope representation of a datapoint as
42+
it travels through the network to then verify if it can have its class changed given a certain perturbation.
4543
4644
| Paper link: https://papers.nips.cc/paper/2018/file/f2f446980d8e971ef3da97af089481c3-Paper.pdf
4745
"""
@@ -166,6 +164,7 @@ def forward_hook(input_module, hook_input, hook_output):
166164
def forward(self, cent: np.ndarray, eps: np.ndarray) -> Tuple["torch.Tensor", "torch.Tensor"]:
167165
"""
168166
Do the forward pass through the NN with the given error terms and zonotope center.
167+
169168
:param eps: Error terms of the zonotope.
170169
:param cent: The datapoint, representing the zonotope center.
171170
:return: A tuple, the first element being the zonotope center vector.

art/estimators/certification/derandomized_smoothing/tensorflow.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from typing import Callable, List, Optional, Tuple, Union, TYPE_CHECKING
2727

2828
import numpy as np
29-
import tensorflow as tf
3029
from tqdm import tqdm
3130

3231
from art.estimators.classification.tensorflow import TensorFlowV2Classifier
@@ -35,6 +34,7 @@
3534

3635
if TYPE_CHECKING:
3736
# pylint: disable=C0412
37+
import tensorflow as tf
3838

3939
from art.utils import CLIP_VALUES_TYPE, PREPROCESSING_TYPE
4040
from art.defences.preprocessor import Preprocessor
@@ -119,6 +119,8 @@ def __init__(
119119
)
120120

121121
def _predict_classifier(self, x: np.ndarray, batch_size: int, training_mode: bool, **kwargs) -> np.ndarray:
122+
import tensorflow as tf # lgtm [py/repeated-import]
123+
122124
outputs = TensorFlowV2Classifier.predict(
123125
self, x=x, batch_size=batch_size, training_mode=training_mode, **kwargs
124126
)

docs/modules/estimators/gan.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
=========================
33
.. automodule:: art.estimators.gan
44

5-
TensorFlow2 GAN
6-
---------------
7-
.. autoclass:: TensorFlow2GAN
5+
TensorFlowV2 GAN
6+
----------------
7+
.. autoclass:: TensorFlowV2GAN
88
:members:
99
:special-members: __init__
1010
:inherited-members:

notebooks/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ demonstrates working Poison Frog (Feature Collision) poisoning attack implemente
240240
[poisoning_attack_feature_collision-pytorch.ipynb](poisoning_attack_feature_collision-pytorch.ipynb) [[on nbviewer](https://nbviewer.jupyter.org/github/Trusted-AI/adversarial-robustness-toolbox/blob/main/notebooks/poisoning_attack_feature_collision-pytorch.ipynb)]
241241
demonstrates working Poison Frog (Feature Collision) poisoning attack implemented in PyTorch Framework on CIFAR10 dataset as per the ([paper](https://arxiv.org/pdf/1804.00792.pdf)). This is a targeted clean label attack, which do not require the attacker to have any control over the labeling of training data and control the behavior of the classifier on a specific test instance without degrading overall classifier performance.
242242

243-
[poisoning_attack_sleeper_agent_pytorch.ipynb](poisoning_attack_sleeper_agent_pytorch.ipynb) [[on nbviewer](https://nbviewer.jupyter.org/github/Trusted-AI/adversarial-robustness-toolbox/blob/main/notebooks/poisoning_attack_sleeper_agent+pytorch.ipynb)]
243+
[poisoning_attack_sleeper_agent_pytorch.ipynb](poisoning_attack_sleeper_agent_pytorch.ipynb) [[on nbviewer](https://nbviewer.jupyter.org/github/Trusted-AI/adversarial-robustness-toolbox/blob/main/notebooks/poisoning_attack_sleeper_agent_pytorch.ipynb)]
244244
demonstrates working Sleeper Agent poisoning attack implemented in PyTorch Framework on CIFAR10 dataset as per the ([paper](https://arxiv.org/pdf/2106.08970.pdf)). A new hidden trigger attack, Sleeper Agent,
245245
which employs gradient matching, data selection, and target model re-training during the crafting process. Sleeper
246246
Agent is the first hidden trigger backdoor attack to be effective against neural networks trained from scratch.

notebooks/attack_attribute_inference.ipynb

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"\n",
4646
"from art.utils import load_nursery\n",
4747
"\n",
48-
"(x_train, y_train), (x_test, y_test), _, _ = load_nursery(test_set=0.2, transform_social=True)"
48+
"(x_train, y_train), (x_test, y_test), _, _ = load_nursery(test_set=0.5, transform_social=True)"
4949
]
5050
},
5151
{
@@ -64,7 +64,7 @@
6464
"name": "stdout",
6565
"output_type": "stream",
6666
"text": [
67-
"Base model accuracy: 0.9791666666666666\n"
67+
"Base model accuracy: 0.9705155912318617\n"
6868
]
6969
}
7070
],
@@ -100,6 +100,7 @@
100100
"\n",
101101
"attack_train_ratio = 0.5\n",
102102
"attack_train_size = int(len(x_train) * attack_train_ratio)\n",
103+
"attack_test_size = int(len(x_train) * attack_train_ratio)\n",
103104
"attack_x_train = x_train[:attack_train_size]\n",
104105
"attack_y_train = y_train[:attack_train_size]\n",
105106
"attack_x_test = x_train[attack_train_size:]\n",
@@ -136,7 +137,7 @@
136137
"name": "stdout",
137138
"output_type": "stream",
138139
"text": [
139-
"0.5937861829409494\n"
140+
"0.5998765050941649\n"
140141
]
141142
}
142143
],
@@ -174,7 +175,7 @@
174175
"name": "stdout",
175176
"output_type": "stream",
176177
"text": [
177-
"0.6227325357005017\n"
178+
"0.6288978079654214\n"
178179
]
179180
}
180181
],
@@ -209,7 +210,7 @@
209210
"name": "stdout",
210211
"output_type": "stream",
211212
"text": [
212-
"0.7001157854110382\n"
213+
"0.7005248533497993\n"
213214
]
214215
}
215216
],
@@ -244,9 +245,9 @@
244245
"name": "stdout",
245246
"output_type": "stream",
246247
"text": [
247-
"(0.3501577287066246, 0.2573913043478261)\n",
248-
"(0.34417344173441733, 0.1472463768115942)\n",
249-
"(0.6309341500765697, 0.23884057971014494)\n"
248+
"(0.34232954545454547, 0.22439478584729983)\n",
249+
"(0.32320441988950277, 0.10893854748603352)\n",
250+
"(0.652046783625731, 0.20763500931098697)\n"
250251
]
251252
}
252253
],
@@ -299,7 +300,7 @@
299300
"name": "stdout",
300301
"output_type": "stream",
301302
"text": [
302-
"0.5372443072172907\n"
303+
"0.5433775856745909\n"
303304
]
304305
}
305306
],
@@ -344,7 +345,7 @@
344345
"\n",
345346
"mem_attack = MembershipInferenceBlackBox(art_classifier)\n",
346347
"\n",
347-
"mem_attack.fit(x_train[:attack_train_size], y_train[:attack_train_size], x_test, y_test)"
348+
"mem_attack.fit(x_train[:attack_train_size], y_train[:attack_train_size], x_test[:attack_test_size], y_test[:attack_test_size])"
348349
]
349350
},
350351
{
@@ -356,14 +357,14 @@
356357
},
357358
{
358359
"cell_type": "code",
359-
"execution_count": 10,
360+
"execution_count": 11,
360361
"metadata": {},
361362
"outputs": [
362363
{
363364
"name": "stdout",
364365
"output_type": "stream",
365366
"text": [
366-
"0.6358548822848321\n"
367+
"0.6335288669342389\n"
367368
]
368369
}
369370
],

0 commit comments

Comments
 (0)