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

Fix ActivationDefense and SpectralSignatures expected flattened bug #2327

Merged
merged 5 commits into from
Dec 20, 2023

Conversation

f4str
Copy link
Collaborator

@f4str f4str commented Nov 14, 2023

Description

Modify the ActivateDefense and SpectralSignatures poisoning defenses to flatten the outputs when calling get_activations() on the estimator.

Additionally, the hack in HuggingFace classifier to use the inputs post-flattening was removed since the defenses will now do the flattening and work with any arbitrary layer.

Fixes #2313

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.

  • Tests for Activation Defense are unchanged
  • Tests for Spectral Signatures are unchanged

Test Configuration:

  • OS
  • Python version
  • ART version or commit number
  • TensorFlow / Keras / PyTorch / MXNet version

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
  • My changes have been tested using both CPU and GPU devices

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>
Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>
@codecov-commenter
Copy link

codecov-commenter commented Nov 14, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a281f62) 76.18% compared to head (fc7cbcb) 84.09%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff               @@
##           dev_1.17.0    #2327      +/-   ##
==============================================
+ Coverage       76.18%   84.09%   +7.90%     
==============================================
  Files             327      327              
  Lines           30850    30852       +2     
  Branches         5716     5716              
==============================================
+ Hits            23503    25944    +2441     
+ Misses           5914     3448    -2466     
- Partials         1433     1460      +27     
Files Coverage Δ
art/defences/detector/poison/activation_defence.py 83.28% <100.00%> (+0.04%) ⬆️
...nces/detector/poison/spectral_signature_defense.py 84.72% <100.00%> (+0.21%) ⬆️

... and 63 files with indirect coverage changes

@f4str f4str marked this pull request as ready for review November 15, 2023 18:16
@beat-buesser beat-buesser self-requested a review November 30, 2023 15:52
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 @f4str Thank you very much for your pull request! It looks good to me.

@beat-buesser beat-buesser self-assigned this Nov 30, 2023
@beat-buesser beat-buesser added bug Something isn't working improvement Improve implementation labels Nov 30, 2023
@beat-buesser beat-buesser added this to the ART 1.17.0 milestone Nov 30, 2023
@f4str
Copy link
Collaborator Author

f4str commented Dec 8, 2023

Due to issues with GitHub actions tests failing, removing the hack in the HuggingFace classifier to use the inputs post-flattening will not be included in this PR. Once the failed unit test is further investigated, the change will be revisited.

@beat-buesser beat-buesser merged commit 95c778e into Trusted-AI:dev_1.17.0 Dec 20, 2023
35 checks passed
@f4str f4str deleted the activation-defense-bug branch December 21, 2023 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working improvement Improve implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ActivationDefense and SpectralSignatures expect flattened activations
3 participants