IntelLabs / MART

Modular Adversarial Robustness Toolkit
BSD 3-Clause "New" or "Revised" License
16 stars 0 forks source link

Prepare target models before running attacks #249

Closed mzweilin closed 2 months ago

mzweilin commented 2 months ago

What does this PR do?

This PR adds two preparations before running attacks in an external Lightning pipeline.

  1. Turn off the PyTorch inference mode, so that we can create perturbation variables that require gradients.
  2. Switch the target model to the training mode except for BatchNorm and Dropout layers, if we have to borrow training_step().

Type of change

Please check all relevant options.

Testing

Please describe the tests that you ran to verify your changes. Consider listing any relevant details of your test configuration.

Before submitting

Did you have fun?

Make sure you had fun coding 🙃