Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of SmoothMix Training in the Randomized Smoothing Module #1668

Closed
wants to merge 78 commits into from

Conversation

asarj
Copy link

@asarj asarj commented May 6, 2022

Description

  • Added support for SmoothMix training on Randomized Smoothing classifiers.
  • Added a train_method argument in the fit method via kwargs with support for SmoothMix training.
  • Added additional params in the RandomizedSmoothingMixin and PyTorchRandomizedSmoothing modules with the parameters needed to train the classifier properly.
  • Implemented a fit_pytorch method that performs the SmoothMix training via PyTorch

Paper Link: https://arxiv.org/pdf/2111.09277.pdf
Code Repository based on paper: https://github.com/jh-jeong/smoothmix

Fixes # (issue)

Type of change

Please check all relevant options.

  • 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.

  • Test A
  • Test B

Test Configuration:

  • OS: Ubuntu 22.04 LTS
  • Python version: 3.7
  • ART version or commit number: 1.10.0
  • TensorFlow / Keras / PyTorch / MXNet version: PyTorch 1.11.0+cu113

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

asarj added 25 commits April 28, 2022 15:21
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
…ated fit_pytorch

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
…f test results

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
@lgtm-com
Copy link

lgtm-com bot commented May 6, 2022

This pull request introduces 9 alerts when merging fa16b0e into e4efd6d - view on LGTM.com

new alerts:

  • 6 for Unused import
  • 1 for Module is imported more than once
  • 1 for Unused local variable
  • 1 for Module is imported with 'import' and 'import from'

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
@asarj asarj marked this pull request as draft May 6, 2022 17:16
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
@lgtm-com
Copy link

lgtm-com bot commented May 6, 2022

This pull request introduces 1 alert when merging bcb3988 into e4efd6d - view on LGTM.com

new alerts:

  • 1 for Module is imported more than once

asarj added 9 commits May 10, 2022 22:13
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
@asarj
Copy link
Author

asarj commented May 11, 2022

Thanks for the heads up @beat-buesser, I've never used git cherry-pick before, but I think I addressed the mistakenly signed commits by switching to the dev_1.11.0 branch, cherry-picking my commits specifically, and pushing that back to the smoothmix branch. Can you please take a look and let me know if this has been resolved?

asarj added 3 commits May 10, 2022 23:14
…ess-toolbox into smoothmix

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
@lgtm-com
Copy link

lgtm-com bot commented May 11, 2022

This pull request fixes 1 alert when merging c1c72ec into 8df19af - view on LGTM.com

fixed alerts:

  • 1 for Module is imported more than once

@asarj
Copy link
Author

asarj commented May 11, 2022

Also @beat-buesser, do I need to address anything from the lgtm-com bot's recent comment on fixing one alert?

asarj added 2 commits May 11, 2022 18:33
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
…lso tensorflowfasterrcnn fix)

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
@beat-buesser
Copy link
Collaborator

Hi @asarj Can you check the commits again, it looks like there are some unrelated commits left from May 8.

Can we implement SmoothMixPGD in art.attacks.evasion inheriting from art.atttacks.attack.EvasionAttack?

Can we move the training procedure in to the fit method of the randomised smoothing estimator?

Should we create a separate estimator for SmoothMix? I think SmoothMix is adding a large umber of arguments to the randomised smoothing estimator which might make it more challenging to recognise which arguments are required for randomised smoothing.

@asarj
Copy link
Author

asarj commented May 17, 2022

@beat-buesser I can create a separate estimator for smoothmix and model this based on the randomized smoothing estimator and look into implementing SmoothMixPGD inheriting from art.atttacks.attack.EvasionAttack but this will take some time

asarj added a commit to Ethos-lab/adversarial-robustness-toolbox that referenced this pull request May 19, 2022
Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
@asarj asarj mentioned this pull request May 19, 2022
14 tasks
@asarj
Copy link
Author

asarj commented May 19, 2022

Closing this because the changes have undergone a refactor based on recent feedback and are in a new PR found here: #1705 (comment).

@asarj asarj closed this May 19, 2022
@f4str f4str deleted the smoothmix branch January 10, 2023 19:47
@f4str f4str mentioned this pull request Jan 11, 2023
13 tasks
f4str added a commit to Ethos-lab/adversarial-robustness-toolbox that referenced this pull request Apr 20, 2023
* added files from PR Trusted-AI#1668

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* moved smoothmix training to fit method of smoothmix estimator and created a separate estimator for smoothmix

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* added unit test for SmoothMix estimator

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* added demo notebook for smoothmix estimator

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* formatting test for smoothmix

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* fixed typo in smoothmix test

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* reverted randomized smoothing tests file to original state

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* removed unecessary gaussian augmentation import

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* fixed ART repo checks errors

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* fixed argument error in demo notebook

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* flake8 test fix

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* cleanup smoothmix

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>

* cleanup notebook and unit tests

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>

* update smoothmix to be compatible with ART 1.14

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>

* consolidate pytorch smoothmix implementation

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>

* cleanup and lint

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>

* update notebook readme with smoothmix demo

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>

* fixed smoothmix unit test

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>

* upgrade smoothmix unit tests to pytest

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>

* refactor smoothmix into randomized smoothing module

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>

---------

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>
Co-authored-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
f4str added a commit to Ethos-lab/adversarial-robustness-toolbox that referenced this pull request Apr 21, 2023
* added files from PR Trusted-AI#1668

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* moved smoothmix training to fit method of smoothmix estimator and created a separate estimator for smoothmix

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* added unit test for SmoothMix estimator

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* added demo notebook for smoothmix estimator

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* formatting test for smoothmix

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* fixed typo in smoothmix test

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* reverted randomized smoothing tests file to original state

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* removed unecessary gaussian augmentation import

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* fixed ART repo checks errors

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* fixed argument error in demo notebook

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* flake8 test fix

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>

* cleanup smoothmix

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>

* cleanup notebook and unit tests

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>

* update smoothmix to be compatible with ART 1.14

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>

* consolidate pytorch smoothmix implementation

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>

* cleanup and lint

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>

* update notebook readme with smoothmix demo

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>

* fixed smoothmix unit test

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>

* upgrade smoothmix unit tests to pytest

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>

* refactor smoothmix into randomized smoothing module

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>

---------

Signed-off-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>
Co-authored-by: Ajay Sarjoo <ajay.sarjoo@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants