Skip to content

Commit

Permalink
added a verbose param to Adversarial for easier interactive usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Rauber committed Jun 23, 2017
1 parent cb27d1c commit e98eaa3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion foolbox/adversarial.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ def __init__(
criterion,
original_image,
original_class,
distance=MSE):
distance=MSE,
verbose=False):

self.__model = model
self.__criterion = criterion
self.__original_image = original_image
self.__original_class = original_class
self.__distance = distance
self.verbose = verbose

self.__best_adversarial = None
self.__best_distance = distance(value=np.inf)
Expand Down Expand Up @@ -97,6 +99,8 @@ def __new_adversarial(self, image):
distance = self.normalized_distance(image)
if self.__best_distance > distance:
# new best adversarial
if self.verbose:
print('new best adversarial: {}'.format(distance))

self.__best_adversarial = image
self.__best_distance = distance
Expand Down

0 comments on commit e98eaa3

Please sign in to comment.