Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/pralab/secml-torch
Browse files Browse the repository at this point in the history
  • Loading branch information
maurapintor committed Nov 2, 2024
2 parents 4c58f2f + 77afc30 commit 753b1d6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ The library can be installed together with other plugins that enable further fun

* [Foolbox](https://github.com/bethgelab/foolbox), a Python toolbox to create adversarial examples.
* [Tensorboard](https://www.tensorflow.org/tensorboard), a visualization toolkit for machine learning experimentation.
* [Adversarial Library](https://github.com/jeromerony/adversarial-library), a powerful library of various adversarial attacks resources in PyTorch.

Install one or more extras with the command:
```bash
pip install secml-torch[foolbox,tensorboard]
```

To enable the `adv_lib` extra, you have to manually install the library from the original repository:

Install one or more extras with the command:
```bash
pip install git+https://github.com/jeromerony/adversarial-library
pip install secml-torch[foolbox,tensorboard, adv_lib]
```

## Key Features
Expand Down
2 changes: 1 addition & 1 deletion src/secmlt/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.1
1.2.2
6 changes: 4 additions & 2 deletions src/secmlt/adv/evasion/modular_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def _init_perturbation_constraints(self) -> list[Constraint]:
raise NotImplementedError(msg)

def _create_optimizer(self, delta: torch.Tensor, **kwargs) -> Optimizer:
return self.optimizer_cls([delta], **kwargs)
return self.optimizer_cls([delta], lr=self.step_size, **kwargs)

def forward_loss(
self, model: BaseModel, x: torch.Tensor, target: torch.Tensor
Expand Down Expand Up @@ -181,8 +181,10 @@ def _run(
samples: torch.Tensor,
labels: torch.Tensor,
init_deltas: torch.Tensor = None,
**optim_kwargs,
optim_kwargs: dict | None = None,
) -> tuple[torch.Tensor, torch.Tensor]:
if optim_kwargs is None:
optim_kwargs = {}
multiplier = 1 if self.y_target is not None else -1
target = (
torch.zeros_like(labels) + self.y_target
Expand Down

0 comments on commit 753b1d6

Please sign in to comment.