Skip to content

Commit 202cb2e

Browse files
Irina NicolaeIrina Nicolae
authored andcommitted
Fix TextFGSM to add batch size
1 parent fdbe843 commit 202cb2e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

art/attacks/configurable_text_attack.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ def uses_embedding(self):
1818
return True
1919

2020
def __call__(self, classifier, x, y):
21-
x_embed = classifier.to_embedding(x)
22-
x_embed_adv = x_embed + \
23-
self.eps * classifier.loss_gradient(np.expand_dims(x, axis=0), np.expand_dims(y, axis=0))[0]
21+
batch_x = np.expand_dims(x, axis=0)
22+
x_embed = classifier.to_embedding(batch_x)
23+
x_embed_adv = x_embed + self.eps * classifier.loss_gradient(batch_x, np.expand_dims(y, axis=0))[0]
2424
return x_embed_adv
2525

2626

0 commit comments

Comments
 (0)