Skip to content

Commit

Permalink
Add tqdm for the attack loop
Browse files Browse the repository at this point in the history
Use tqdm indication bar showing the attack iterations.

Signed-off-by: Teodora Sechkova <[email protected]>
  • Loading branch information
sechkova committed Aug 25, 2023
1 parent 2b88f87 commit 2199fac
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion art/attacks/evasion/patchfool.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from typing import Optional, Union

import numpy as np
from tqdm import tqdm

from art.attacks.attack import EvasionAttack
from art.estimators.classification.pytorch import PyTorchClassifierDeiT
Expand Down Expand Up @@ -137,7 +138,7 @@ def _generate_batch(self, x: "torch.Tensor", y: Optional["torch.Tensor"] = None)
optim = torch.optim.Adam([perturbation], lr=self.learning_rate)
scheduler = torch.optim.lr_scheduler.StepLR(optim, step_size=self.step_size, gamma=self.step_size_decay)

for i_max_iter in range(self.max_iter):
for i_max_iter in tqdm(range(self.max_iter)):

Check failure

Code scanning / CodeQL

Suspicious unused loop iteration variable Error

For loop variable 'i_max_iter' is not used in the loop body.

self.estimator.model.zero_grad()
optim.zero_grad()
Expand Down

0 comments on commit 2199fac

Please sign in to comment.