Skip to content

Commit

Permalink
Update fgsm.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcarter23 authored Dec 4, 2024
1 parent 787b4b0 commit f64deda
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion adversarial_attack/fgsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def targeted_attack(
grad = compute_gradient(model=model, input=adv_tensor, target=target)
adv_tensor = torch.clamp(adv_tensor - epsilon * grad.sign(), -2, 2)
new_pred = model(adv_tensor).argmax()
if orig_pred_idx.item() != new_pred:
if orig_pred_idx.item() == target.item():
return adv_tensor, orig_pred, new_pred

warnings.warn(
Expand Down

0 comments on commit f64deda

Please sign in to comment.