Skip to content

Commit 0535c79

Browse files
authored
Merge pull request #2129 from Lodour/fix_signopt_duplicated_queries
Remove incorrectly duplicated queries in SignOPT attack
2 parents b13f802 + 4a9ef03 commit 0535c79

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

art/attacks/evasion/sign_opt.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,14 @@ def _fine_grained_binary_search_local(
306306
lbd = initial_lbd
307307
# For targeted: we want to expand(x1.01) boundary away from targeted dataset
308308
# For untargeted, we want to slim(x0.99) the boundary toward the original dataset
309-
if (not self._is_label(x_0 + lbd * theta, target) and self.targeted) or (
310-
self._is_label(x_0 + lbd * theta, y_0) and not self.targeted
309+
if (self.targeted and not self._is_label(x_0 + lbd * theta, target)) or (
310+
not self.targeted and self._is_label(x_0 + lbd * theta, y_0)
311311
):
312312
lbd_lo = lbd
313313
lbd_hi = lbd * 1.01
314314
nquery += 1
315-
while (not self._is_label(x_0 + lbd_hi * theta, target) and self.targeted) or (
316-
self._is_label(x_0 + lbd_hi * theta, y_0) and not self.targeted
315+
while (self.targeted and not self._is_label(x_0 + lbd_hi * theta, target)) or (
316+
not self.targeted and self._is_label(x_0 + lbd_hi * theta, y_0)
317317
):
318318
lbd_hi = lbd_hi * 1.01
319319
nquery += 1
@@ -323,17 +323,17 @@ def _fine_grained_binary_search_local(
323323
lbd_hi = lbd
324324
lbd_lo = lbd * 0.99
325325
nquery += 1
326-
while (self._is_label(x_0 + lbd_lo * theta, target) and self.targeted) or (
327-
not self._is_label(x_0 + lbd_lo * theta, y_0) and not self.targeted
326+
while (self.targeted and self._is_label(x_0 + lbd_lo * theta, target)) or (
327+
not self.targeted and not self._is_label(x_0 + lbd_lo * theta, y_0)
328328
):
329329
lbd_lo = lbd_lo * 0.99
330330
nquery += 1
331331

332332
while (lbd_hi - lbd_lo) > tol:
333333
lbd_mid = (lbd_lo + lbd_hi) / 2.0
334334
nquery += 1
335-
if (self._is_label(x_0 + lbd_mid * theta, target) and self.targeted) or (
336-
not self._is_label(x_0 + lbd_mid * theta, y_0) and not self.targeted
335+
if (self.targeted and self._is_label(x_0 + lbd_mid * theta, target)) or (
336+
not self.targeted and not self._is_label(x_0 + lbd_mid * theta, y_0)
337337
):
338338
lbd_hi = lbd_mid
339339
else:

requirements_test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ scipy==1.10.1
55
matplotlib==3.7.1
66
scikit-learn>=0.22.2,<1.2.0
77
six==1.16.0
8-
Pillow==9.4.0
8+
Pillow==9.5.0
99
tqdm==4.65.0
1010
statsmodels==0.13.5
1111
pydub==0.25.1

0 commit comments

Comments
 (0)