Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions common/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ def evaluate(self, defense, example_idx, true_label,
if distortion > self.threshold + 1e-3:
return False, "Distortion {} exceeds bound {}".format(distortion, self.threshold)

# Verify that example is within [0, 1] domain of input images
min_val = np.min(adv_example)
max_val = np.max(adv_example)
if min_val < 0.0:
return False, "Adversarial example min value {} is outside of [0, 1] range".format(min_val)
if max_val > 1.0:
return False, "Adversarial example max value {} is outside of [0, 1] range".format(max_val)

# Verify that it's not detected as adversarial
if adv_detector > defense.threshold:
return False, "Adversarial example rejected by detector with score {}.".format(adv_detector)
Expand Down