This PR updates GradientModifier to be an in-place operation like torch.nn.utils.clip_gradnorm. This also adds a test to make sure Adversary is properly modifying gradients.
Type of change
Please check all relevant options.
[x] Improvement (non-breaking)
[ ] Bug fix (non-breaking)
[ ] New feature (non-breaking)
[ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
[ ] This change requires a documentation update
Testing
Please describe the tests that you ran to verify your changes. Consider listing any relevant details of your test configuration.
[x] make test
[x] CIFAR10_CNN_Adv achieves ~70% accuracy
Before submitting
[x] The title is self-explanatory and the description concisely explains the PR
[x] My PR does only one thing, instead of bundling different changes together
[x] I list all the breaking changes introduced by this pull request
[x] I have commented my code
[x] I have added tests that prove my fix is effective or that my feature works
[x] New and existing unit tests pass locally with my changes
[x] I have run pre-commit hooks with pre-commit run -a command without errors
What does this PR do?
This PR updates GradientModifier to be an in-place operation like torch.nn.utils.clip_gradnorm. This also adds a test to make sure Adversary is properly modifying gradients.
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.
make test
CIFAR10_CNN_Adv
achieves ~70% accuracyBefore submitting
pre-commit run -a
command without errorsDid you have fun?
Make sure you had fun coding 🙃