Skip to content

Commit

Permalink
implemented repeated version
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-schott committed Mar 24, 2020
1 parent 90d7835 commit 43dbda1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion foolbox/attacks/spatial_attack.py
Expand Up @@ -114,4 +114,17 @@ def random_search_generator() -> Generator[Any, Any, Any]:
return restore_type(results)

def repeat(self, times: int) -> Attack:
raise NotImplementedError
if self.grid_search:
raise ValueError(
"repeat is not supported if attack is deterministic"
) # attack is deterministic
else:
random_steps = self.random_steps * times
return SpatialAttack(
max_translation=self.max_trans,
max_rotation=self.max_rot,
num_translations=self.num_trans,
num_rotations=self.num_rots,
grid_search=self.grid_search,
random_steps=random_steps,
)

0 comments on commit 43dbda1

Please sign in to comment.