bethgelab / foolbox

A Python toolbox to create adversarial examples that fool neural networks in PyTorch, TensorFlow, and JAX
https://foolbox.jonasrauber.de
MIT License
2.71k stars 422 forks source link

model.eval() #648

Closed zerortj closed 2 years ago

zerortj commented 2 years ago

Why did the robust accuracy drop dramatically after I used model.eval()?

FlorianMerkle commented 2 years ago

It is hard to tell without knowing more about your case but if you utilize BatchNorm Layers in your model, you might want to check if you are using your model in the correct mode (e.g. when crafting adversarial examples it should be in evaluation mode already). Anyways, Foolbox should give you a warning if you forget to call model.eval() before transforming your model into a Foolbox model. If you mind sharing your script, we can have a closer look.

zimmerrol commented 2 years ago

As mentioned by @FlorianMerkle this can have different reasons. Unless you provide the code that caused this behavior there is nothing we can do. However, note that most likely this is not a bug in foolbox but just the behavior of your model.