Skip to content

Commit 14b0b03

Browse files
committed
resolve comments for clever
1 parent 80c9f63 commit 14b0b03

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/metrics.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def clever_u(x, classifier, n_b, n_s, r, sess, c_init=1):
167167
:param r: maximum perturbation
168168
:param sess:
169169
:param c_init: initialization of Weibull distribution
170-
:return: CLEVER score
170+
:return: a tuple of 3 CLEVER scores, corresponding to norm 1, 2, inf.
171171
"""
172172
# Get a list of untargeted classes
173173
y_pred = classifier.predict(np.array([x]))
@@ -183,7 +183,7 @@ def clever_u(x, classifier, n_b, n_s, r, sess, c_init=1):
183183
score2_list.append(s2)
184184
score8_list.append(s8)
185185

186-
return np.min(score1_list), np.min(score2_list), np.min(score8_list)
186+
return tuple((np.min(score1_list), np.min(score2_list), np.min(score8_list)))
187187

188188

189189
def clever_t(x, classifier, target_class, n_b, n_s, r, sess, c_init=1):
@@ -198,7 +198,7 @@ def clever_t(x, classifier, target_class, n_b, n_s, r, sess, c_init=1):
198198
:param r: maximum perturbation
199199
:param sess:
200200
:param c_init: initialization of Weibull distribution
201-
:return: CLEVER score
201+
:return: a tuple of 3 CLEVER scores, corresponding to norm 1, 2, inf.
202202
"""
203203
# Check if the targeted class is different from the predicted class
204204
y_pred = classifier.predict(np.array([x]))
@@ -270,7 +270,7 @@ def clever_t(x, classifier, target_class, n_b, n_s, r, sess, c_init=1):
270270
s2 = np.min([-g_x0[0] / loc2, r])
271271
s1 = np.min([-g_x0[0] / loc8, r])
272272

273-
return s1, s2, s8
273+
return tuple((s1, s2, s8))
274274

275275

276276
def _build_g_gradient(x, classifier, pred_class, target_class):

0 commit comments

Comments
 (0)