Skip to content

Commit

Permalink
Fix renorm dimension in random_perturb
Browse files Browse the repository at this point in the history
  • Loading branch information
dtsip committed Feb 11, 2020
1 parent ca52df7 commit a733a88
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions robustness/attack_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def step(self, x, g):
def random_perturb(self, x):
"""
"""
new_x = x + (ch.rand_like(x) - 0.5).renorm(p=2, dim=1, maxnorm=self.eps)
new_x = x + (ch.rand_like(x) - 0.5).renorm(p=2, dim=0, maxnorm=self.eps)
return ch.clamp(new_x, 0, 1)

# Unconstrained threat model
Expand All @@ -152,7 +152,7 @@ def step(self, x, g):
def random_perturb(self, x):
"""
"""
new_x = x + (ch.rand_like(x) - 0.5).renorm(p=2, dim=1, maxnorm=step_size)
new_x = x + (ch.rand_like(x) - 0.5).renorm(p=2, dim=0, maxnorm=step_size)
return ch.clamp(new_x, 0, 1)

class FourierStep(AttackerStep):
Expand Down

0 comments on commit a733a88

Please sign in to comment.