Comments (1)
Hi, thank you for suggesting an attack to implement.
However, in the case of l_inf, Carlini, et al. recommend using PGD instead of CW.
Nevertheless, if you have to use CW, please use the below code following here and here.
import torch
import torch.nn as nn
import torch.optim as optim
from torchattacks.attack import Attack
import art.attacks.evasion as evasion
from art.classifiers import PyTorchClassifier
class CWLinf(Attack):
def __init__(self, model, confidence=0.0,
targeted=False, learning_rate=0.01, max_iter=10,
max_halving=5, max_doubling=5, eps=0.3, batch_size=128):
super(CWLinf, self).__init__("CWLinf", model)
self.classifier = PyTorchClassifier(
model=self.model, clip_values=(0, 1),
loss=nn.CrossEntropyLoss(),
optimizer=optim.Adam(self.model.parameters(), lr=0.01),
input_shape=(1, 28, 28), nb_classes=10)
self.adversary = evasion.CarliniLInfMethod(classifier=self.classifier,
targeted=targeted,
learning_rate=learning_rate,
max_iter=max_iter, max_halving=max_halving,
max_doubling=max_doubling, eps=eps,
batch_size=batch_size)
self._attack_mode = 'only_default'
def forward(self, images, labels):
adv_images = self.adversary.generate(images, labels)
return torch.tensor(adv_images).to(self.device)
from adversarial-attacks-pytorch.
Related Issues (20)
- [FEATURE] Target attack of PI-FGSM HOT 4
- TorchAttack for Quantised pytorch model HOT 7
- [QUESTION]autoattack in binary classification
- [BUG]if use pip install torchattacks, the DeepFool is wrong HOT 3
- [QUESTION] Using this on blip captioner HOT 5
- [BUG] Getting same image as input HOT 6
- [QUESTION]The 'inf' in 'deepfool.py' HOT 2
- [BUG]when i use pip to install the new version, it uinstall my cuda and torch(1.12.0) and install the cpu version(1.13.0) HOT 2
- [QUESTION] About check_validity function HOT 2
- [BUG] no function "set_training_mode" but "set_model_training_mode" instead HOT 3
- [BUG] Incorrect random start of PGD L2 HOT 2
- one pixel numpy, tensor incompatiblity HOT 1
- [BUG] miss of res for L1 in torchattack.fab.py HOT 1
- [QUESTION] What is the difference between autoattack.py in this repository and autoattack.py in the auto-attack repository? HOT 1
- The model loading in the demo seems to have become inactive[BUG] HOT 11
- [QUESTION] Binary search for Carlini-Wagner HOT 4
- Adversarial Training HOT 2
- One of the differentiated Tensors appears to not have been used in the graph. Set allow_unused=True if this is the desired behavior. HOT 4
- [QUESTION] Low success rate for the Carlini-Wagner attack. HOT 7
- torchattacks.FGSM(model, eps=0) perturbs image HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adversarial-attacks-pytorch.