Skip to main content

adv-ml

Docs

See https://irad-zehavi.github.io/adv-ml/

Install

pip install adv_ml

How to use

How to Use

As an nbdev library, adv-ml supports import * (without importing unwanted symbols):

from adv_ml.all import *

Adversarial Examples

mnist = MNIST()
classifier = MLP(10)
learn = Learner(mnist.dls(), classifier, metrics=accuracy)
learn.fit(1)
epoch train_loss valid_loss accuracy time
0 0.154410 0.177410 0.953900 00:32
sub_dsets = mnist.valid.random_sub_dsets(64)
learn.show_results(shuffle=False, dl=sub_dsets.dl())

attack = InputOptimizer(classifier, LinfPGD(epsilon=.15), n_epochs=10, epoch_size=20)
perturbed_dsets = attack.perturb(sub_dsets)
epoch train_loss time
0 -4.302573 00:00
1 -7.585707 00:00
2 -9.014968 00:00
3 -9.700548 00:00
4 -10.075110 00:00
5 -10.296636 00:00
6 -10.433834 00:00
7 -10.521141 00:00
8 -10.577673 00:00
9 -10.614740 00:00
learn.show_results(shuffle=False, dl=TfmdDL(perturbed_dsets))

Data Poisoning

patch = torch.tensor([[1, 0, 1],
                      [0, 1, 0],
                      [1, 0, 1]]).int()*255
trigger = F.pad(patch, (25, 0, 25, 0)).numpy()
learn = Learner(mnist.dls(), MLP(10), metrics=accuracy, cbs=BadNetsAttack(trigger, '0'))
learn.fit_one_cycle(1)
epoch train_loss valid_loss accuracy time
0 0.103652 0.097075 0.971400 00:23

Benign performance:

learn.show_results()

Attack success:

learn.show_results(2)

Metadata

Release files for adv-ml 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for adv-ml 0.0.4
File Size Uploaded Provenance Actions
adv-ml-0.0.4.tar.gz 22.0 kB Without provenance Details for adv-ml-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for adv-ml 0.0.4
File Interpreter ABI Platform Actions
adv_ml-0.0.4-py3-none-any.whl Python 3 none any Details for adv_ml-0.0.4-py3-none-any.whl

Total release size: 42.7 kB

Release files / adv-ml-0.0.4.tar.gz

Download URL adv-ml-0.0.4.tar.gz
Size 22.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fb99423d52072d8e4e1919e8fd3f59c6f259c2e3b756bc38ea0849b9f0437927
BLAKE2b-256 checksum
How to use checksums
8d6208d24ee327042bf70bef28680a06253757222a0c24032da9ecdf98c171fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / adv_ml-0.0.4-py3-none-any.whl

Download URL adv_ml-0.0.4-py3-none-any.whl
Size 20.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1c284973cac35915fa50ad4ae513a7069b594ece6faeb32fda5e869ad0e013f
BLAKE2b-256 checksum
How to use checksums
d8afb3dfb924c69cdb1084ce08107c4072f5e5e94414489803f8da6d7dddde4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Security for adv-ml 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page