Comments (5)
Hi, @Jindong-Explainable-AI! I managed to reproduce your error. In the code you posted, there is an error in input_shape
when you create the PyTorchClassifier
object: you use (3, 244, 244)
instead of (3, 224, 224)
. 😄 Correcting these values will allow you to use the attacks.
from adversarial-robustness-toolbox.
Thanks for this! Sorry for such an embarrassing error.
FastGradientMethod, BIM use loss_gradient() where assert grds.shape == x.shape
In CarliniL2Method, it uses class_gradient() where assert grds.shape == (x_.shape[0], self.nb_classes) + self.input_shape
The first one has nothing to do with the specified input shape.
That is why one works, it does not work for the other!
Okay, Thanks a lot!
from adversarial-robustness-toolbox.
Hi, @Jindong-Explainable-AI! The fact that you get the error for C&W and DeepFool, but not FGSM confirms that the problem comes from the implementation of class gradients for the PyTorch wrapper. A couple of questions:
- Could you confirm that you pass
input_shape=(3, 224, 224)
toPyTorchClassifier
when you create the object? - Is the model you are using one of the standard Imagenet models? This would help us reproduce the error on our side.
from adversarial-robustness-toolbox.
Hi, @Irina Nicolae Thanks for the response! I reinstalled the package again with pip command and also manually. And run the code, get the same error! I also tried with different (input_shape) e.g. (224, 224), (1, 224, 224), (1, 3, 224, 224), (3, 224, 224), (224, 224, 3) and so on, still the same error.
from adversarial-robustness-toolbox.
model = models.vgg16(pretrained=True)
classifier = PyTorchClassifier(clip_values=(-2.11790394, 2.2489084), model=model, loss= nn.CrossEntropyLoss(), optimizer= torch.optim.SGD(model.parameters(), lr = 0.01), input_shape=(3, 244, 244), nb_classes = 1000, defences = None, preprocessing=(0, 1))
adv = CarliniL2Method(classifier, targeted=False, max_iter=10, binary_search_steps=10, learning_rate=0.01)
adv.generate(img_variable.data.numpy())
the shape of img_variable.data.numpy() is (1, 3, 224, 224)
FYI to reproduce the error!
from adversarial-robustness-toolbox.
Related Issues (20)
- Not generating Adversarial examples HOT 1
- PyTorch classes that check torch.optim.lr_scheduler._LRScheduler HOT 1
- AdversarialTrainer parameter name missmatch HOT 2
- Incorrect Documentation regarding attacks.poisoning HOT 1
- Auto PGD not working with DLR loss for binary classification HOT 1
- ERROR collecting tests/attacks/evasion/test_brendel_and_bethge.py
- Measured Linf norm exceeds epsilon for ACG HOT 1
- Risky values in tests
- Gradient Explosion
- Robust
- Rr
- adversarial audio example notebook not giving the same results HOT 2
- Unable to utilize PytorchClassifier for ASR model HOT 1
- List of projects/tools utilising ART [JATIC-I4-IBM]
- Attack > Evasion > Momentum Iterative Method: major issues HOT 1
- Package cannot be imported after installing with pip HOT 3
- Deprecated `pkg_resources` raises `DeprecationWarning`s HOT 3
- UserWarning and RuntimeError in ProjectedGradientDescent due to Non-Writable NumPy Array and Device Mismatch HOT 1
- Acknowledged contributor (mistakenly?) removed from `AUTHORS` off-PR HOT 2
- KerasClassifier not compatible with latest versions of Keras and TensorFlow HOT 1
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-robustness-toolbox.