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

TRADES adversarial training protocol #2131

Merged
merged 5 commits into from
May 26, 2023

Conversation

Zaid-Hameed
Copy link
Collaborator

@Zaid-Hameed Zaid-Hameed commented May 3, 2023

Description

TRADES is an important adversarial training approach because it provides a better tradeoff between robustness against adversarial attacks and clean accuracy. TRADES has been proposed in paper "Theoretically Principled Trade-off between Robustness and Accuracy".

Paper link: https://proceedings.mlr.press/v97/zhang19p.html

It is also standard component of recent and more advanced adversarial training approaches.

Fixes #2031

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.

  • Trades adversarial training implementation produces results similar to original implementation
  • All functions in implemented code work as expected

Test Configuration:

  • OS: Red Hat Enterprise Linux 8.7 (Ootpa)
  • Python version: 3.9.12
  • ART version or commit number: 1.14.1
  • TensorFlow / Keras / PyTorch / MXNet version: PyTorch 1.13.1+cu117

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

@codecov-commenter
Copy link

codecov-commenter commented May 3, 2023

Codecov Report

Merging #2131 (3fe948d) into dev_1.15.0 (bbb92cf) will increase coverage by 12.24%.
The diff coverage is 89.76%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Impacted file tree graph

@@               Coverage Diff               @@
##           dev_1.15.0    #2131       +/-   ##
===============================================
+ Coverage       73.39%   85.63%   +12.24%     
===============================================
  Files             297      299        +2     
  Lines           26521    26648      +127     
  Branches         4864     4878       +14     
===============================================
+ Hits            19464    22821     +3357     
+ Misses           5930     2580     -3350     
- Partials         1127     1247      +120     
Impacted Files Coverage Δ
...nces/trainer/adversarial_trainer_trades_pytorch.py 87.73% <87.73%> (ø)
art/defences/trainer/__init__.py 100.00% <100.00%> (ø)
art/defences/trainer/adversarial_trainer_trades.py 100.00% <100.00%> (ø)

... and 65 files with indirect coverage changes

@beat-buesser beat-buesser self-requested a review May 3, 2023 20:11
@beat-buesser beat-buesser self-assigned this May 3, 2023
@beat-buesser beat-buesser added the enhancement New feature or request label May 3, 2023
@beat-buesser beat-buesser added this to the ART 1.15.0 milestone May 3, 2023
@beat-buesser beat-buesser linked an issue May 3, 2023 that may be closed by this pull request
@beat-buesser beat-buesser changed the title Trades adversarial training protocol TRADES adversarial training protocol May 10, 2023
@beat-buesser beat-buesser added this to Pull request review in ART 1.15.0 May 10, 2023
Signed-off-by: Muhammad Zaid Hameed <Zaid.Hameed@ibm.com>
Copy link
Collaborator

@beat-buesser beat-buesser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Zaid-Hameed Thank you very much for your pull request! I have a few minor review comments, what do you think?

Muhammad Zaid Hameed added 2 commits May 19, 2023 17:30
Signed-off-by: Muhammad Zaid Hameed <Zaid.Hameed@ibm.com>
Signed-off-by: Muhammad Zaid Hameed <Zaid.Hameed@ibm.com>
raise NotImplementedError

@abc.abstractmethod
def fit_generator(self, generator: DataGenerator, nb_epochs: int = 20, **kwargs):

Check notice

Code scanning / CodeQL

Mismatch between signature and use of an overridden method Note

Overridden method signature does not match
call
, where it is passed too many arguments. Overriding method
method AdversarialTrainerTRADESPyTorch.fit_generator
matches the call.
Overridden method signature does not match
call
, where it is passed an argument named 'scheduler'. Overriding method
method AdversarialTrainerTRADESPyTorch.fit_generator
matches the call.
Muhammad Zaid Hameed and others added 2 commits May 24, 2023 15:34
Copy link
Collaborator

@beat-buesser beat-buesser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Zaid-Hameed Thank you very much and congratulations to your first PR merged to ART!

@beat-buesser beat-buesser merged commit 36bc03d into Trusted-AI:dev_1.15.0 May 26, 2023
37 checks passed
ART 1.15.0 automation moved this from Pull request review to Pull request done May 26, 2023
@Zaid-Hameed
Copy link
Collaborator Author

Thanks a lot @beat-buesser for all the help in it and the review. :)

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
No open projects
ART 1.15.0
Pull request done
Development

Successfully merging this pull request may close these issues.

TRADES adversarial training implementation
3 participants