SecML-Torch Library
Project description
SecML-Torch: A Library for Robustness Evaluation of Deep Learning Models
SecML-Torch (SecMLT) is an open-source Python library designed to facilitate research in the area of Adversarial Machine Learning (AML) and robustness evaluation. The library provides a simple yet powerful interface for generating various types of adversarial examples, as well as tools for evaluating the robustness of machine learning models against such attacks.
Installation
You can install SecMLT via pip:
pip install secml-torch
This will install the core version of SecMLT, including only the main functionalities such as native implementation of attacks and PyTorch wrappers.
Install with extras
The library can be installed together with other plugins that enable further functionalities.
- Foolbox, a Python toolbox to create adversarial examples.
- Tensorboard, a visualization toolkit for machine learning experimentation.
- Adversarial Library, a powerful library of various adversarial attacks resources in PyTorch.
Install one or more extras with the command:
pip install secml-torch[foolbox,tensorboard,adv_lib]
Key Features
- Built for Deep Learning: SecMLT is compatible with the popular machine learning framework PyTorch.
- Various types of adversarial attacks: SecMLT includes support for a wide range of attack methods (evasion, poisoning, ...) such as different implementations imported from popular AML libraries (Foolbox, Adversarial Library).
- Customizable attacks: SecMLT offers several levels of analysis for the models, including modular implementations of existing attacks to extend with different loss functions, optimizers, and more.
- Attack debugging: Built-in debugging of evaluations by logging events and metrics along the attack runs (even on Tensorboard).
Usage
Here's a brief example of using SecMLT to evaluate the robustness of a trained classifier:
from secmlt.adv.evasion.pgd import PGD
from secmlt.metrics.classification import Accuracy
from secmlt.models.pytorch.base_pytorch_nn import BasePytorchClassifier
model = ...
torch_data_loader = ...
# Wrap model
model = BasePytorchClassifier(model)
# create and run attack
attack = PGD(
perturbation_model="l2",
epsilon=0.4,
num_steps=100,
step_size=0.01,
)
adversarial_loader = attack(model, torch_data_loader)
# Test accuracy on adversarial examples
robust_accuracy = Accuracy()(model, adversarial_loader)
For more detailed usage instructions and examples, please refer to the official documentation or to the examples.
Contributing
We welcome contributions from the research community to expand the library's capabilities or add new features. If you would like to contribute to SecMLT, please follow our contribution guidelines.
Acknowledgements
SecML has been partially developed with the support of European Union’s ELSA – European Lighthouse on Secure and Safe AI, Horizon Europe, grant agreement No. 101070617, Sec4AI4Sec - Cybersecurity for AI-Augmented Systems, Horizon Europe, grant agreement No. 101120393, and CoEvolution - A Comprehensive Trustworthy Framework for Connected Machine Learning and Secure Interconnected AI Solutions, Horizon Europe, grant agreement No. 101168560, and by the project SERICS (PE00000014) under the MUR National Recovery and Resilience Plan funded by the European Union - NextGenerationEU.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file secml_torch-1.3.tar.gz.
File metadata
- Download URL: secml_torch-1.3.tar.gz
- Upload date:
- Size: 35.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e665edc2cdc9543d97f35f08782ee49eadef4bbe1eb9e5dc175f94464ea9501
|
|
| MD5 |
7128077a6f3632122eebc4dffeae5eff
|
|
| BLAKE2b-256 |
1bfa3c302f719a913d035d1e1782a981c03d802b246de5a8c48257523e3b27f7
|
Provenance
The following attestation bundles were made for secml_torch-1.3.tar.gz:
Publisher:
release.yml on pralab/secml-torch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
secml_torch-1.3.tar.gz -
Subject digest:
3e665edc2cdc9543d97f35f08782ee49eadef4bbe1eb9e5dc175f94464ea9501 - Sigstore transparency entry: 537842378
- Sigstore integration time:
-
Permalink:
pralab/secml-torch@7bd9d4a5b7bf604a6f649cb304555f497f5e4df0 -
Branch / Tag:
refs/tags/v1.3 - Owner: https://github.com/pralab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7bd9d4a5b7bf604a6f649cb304555f497f5e4df0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file secml_torch-1.3-py3-none-any.whl.
File metadata
- Download URL: secml_torch-1.3-py3-none-any.whl
- Upload date:
- Size: 58.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e163ffe67fe63e86bfb44830e84e9b20390ea979cf1206f856b1fc11c315dd4
|
|
| MD5 |
7af9237f4f1b34c55766ad9f7c169428
|
|
| BLAKE2b-256 |
03d9965390970571795f0ad61e391ea0b14530f92565b921f74968ef06371f40
|
Provenance
The following attestation bundles were made for secml_torch-1.3-py3-none-any.whl:
Publisher:
release.yml on pralab/secml-torch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
secml_torch-1.3-py3-none-any.whl -
Subject digest:
9e163ffe67fe63e86bfb44830e84e9b20390ea979cf1206f856b1fc11c315dd4 - Sigstore transparency entry: 537842391
- Sigstore integration time:
-
Permalink:
pralab/secml-torch@7bd9d4a5b7bf604a6f649cb304555f497f5e4df0 -
Branch / Tag:
refs/tags/v1.3 - Owner: https://github.com/pralab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7bd9d4a5b7bf604a6f649cb304555f497f5e4df0 -
Trigger Event:
release
-
Statement type: