Skip to content

Commit 415e819

Browse files
Irina NicolaeIrina Nicolae
authored andcommitted
Correct norms in Clever metric
1 parent 4df1560 commit 415e819

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

art/metrics.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,6 @@ def clever_t(classifier, x, target_class, n_b, n_s, r, norm, c_init=1, pool_fact
201201
if pool_factor < 1:
202202
raise ValueError("The pool_factor must be larger than 1")
203203

204-
# Change norm since q = p / (p-1)
205-
if norm == 1:
206-
norm = np.inf
207-
elif norm == np.inf:
208-
norm = 1
209-
elif norm != 2:
210-
raise ValueError("Norm {} not supported".format(norm))
211-
212204
# Some auxiliary vars
213205
grad_norm_set = []
214206
dim = reduce(lambda x_, y: x_ * y, x.shape, 1)
@@ -220,6 +212,14 @@ def clever_t(classifier, x, target_class, n_b, n_s, r, norm, c_init=1, pool_fact
220212
rand_pool += np.repeat(np.array([x]), pool_factor * n_s, 0)
221213
np.clip(rand_pool, classifier.clip_values[0], classifier.clip_values[1], out=rand_pool)
222214

215+
# Change norm since q = p / (p-1)
216+
if norm == 1:
217+
norm = np.inf
218+
elif norm == np.inf:
219+
norm = 1
220+
elif norm != 2:
221+
raise ValueError("Norm {} not supported".format(norm))
222+
223223
# Loop over n_b batches
224224
for i in range(n_b):
225225
# Random generation of data points

0 commit comments

Comments
 (0)