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

Randomised smoothing fix #1678

Merged

Conversation

GiulioZizzo
Copy link
Collaborator

Description

The old implementation of randomised smoothing only added noise once to the data. We now add a new noise draw each time the data is seen. For torch and tensorflow we implement a slightly modified version of the normal fitting procedure which uses noise. For numpy we call fit with epoch=1 for the required amount.

We add warnings to the user to be careful with the use of pre-processors as we are adding the noise after their application for torch/tensorflow and before their application for numpy. In either case, the use of pre-processors could cause the expected certification radius to vary.

Fixes #1617

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

existing tests for randomized smoothing pass

Test Configuration:

  • OS: RHEL 8
  • Python version: 3.9
  • ART version or commit number: 1.10.0
  • TensorFlow / Keras / PyTorch / MXNet version: TF2.8, torch 1.11

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

Signed-off-by: GiulioZizzo <giulio.zizzo@yahoo.co.uk>
Signed-off-by: GiulioZizzo <giulio.zizzo@yahoo.co.uk>
Signed-off-by: GiulioZizzo <giulio.zizzo@yahoo.co.uk>
Signed-off-by: GiulioZizzo <giulio.zizzo@yahoo.co.uk>
Signed-off-by: GiulioZizzo <giulio.zizzo@yahoo.co.uk>
Signed-off-by: GiulioZizzo <giulio.zizzo@yahoo.co.uk>
Signed-off-by: GiulioZizzo <giulio.zizzo@yahoo.co.uk>
@codecov-commenter
Copy link

codecov-commenter commented May 10, 2022

Codecov Report

Merging #1678 (f6b4f91) into dev_1.10.2 (084e976) will decrease coverage by 0.18%.
The diff coverage is 86.27%.

Impacted file tree graph

@@              Coverage Diff               @@
##           dev_1.10.2    #1678      +/-   ##
==============================================
- Coverage       88.13%   87.94%   -0.19%     
==============================================
  Files             259      259              
  Lines           21349    21397      +48     
  Branches         3789     3800      +11     
==============================================
+ Hits            18816    18818       +2     
- Misses           1592     1625      +33     
- Partials          941      954      +13     
Impacted Files Coverage Δ
...mators/certification/randomized_smoothing/numpy.py 85.00% <80.00%> (-2.10%) ⬇️
...s/certification/randomized_smoothing/tensorflow.py 91.37% <81.25%> (-6.35%) ⬇️
...tors/certification/randomized_smoothing/pytorch.py 92.10% <91.66%> (-4.13%) ⬇️
...ation/randomized_smoothing/randomized_smoothing.py 97.33% <100.00%> (-0.11%) ⬇️
...timators/poison_mitigation/neural_cleanse/keras.py 78.47% <0.00%> (-13.89%) ⬇️
art/estimators/certification/abstain.py 90.90% <0.00%> (-9.10%) ⬇️
...poison_mitigation/neural_cleanse/neural_cleanse.py 84.21% <0.00%> (-6.15%) ⬇️
art/estimators/poison_mitigation/strip/strip.py 94.44% <0.00%> (-5.56%) ⬇️
art/defences/preprocessor/mp3_compression.py 84.05% <0.00%> (-5.01%) ⬇️
... and 3 more

Signed-off-by: GiulioZizzo <giulio.zizzo@yahoo.co.uk>
@beat-buesser beat-buesser self-requested a review May 10, 2022 17:07
@beat-buesser beat-buesser self-assigned this May 10, 2022
@beat-buesser beat-buesser added bug Something isn't working improvement Improve implementation labels May 10, 2022
@beat-buesser beat-buesser added this to the ART 1.10.2 milestone May 10, 2022
@beat-buesser beat-buesser linked an issue May 10, 2022 that may be closed by this pull request
@lgtm-com
Copy link

lgtm-com bot commented May 10, 2022

This pull request introduces 2 alerts when merging 048aab5 into 084e976 - view on LGTM.com

new alerts:

  • 2 for Module is imported more than once

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 @GiulioZizzo Thank you very much for noticing this issue and fixing it with your pull request! I have made a few very minor comments on ordering imports and adding comments. What do you think?

GiulioZizzo and others added 4 commits May 13, 2022 18:16
…moothing.py

Co-authored-by: Beat Buesser <49047826+beat-buesser@users.noreply.github.com>
Signed-off-by: GiulioZizzo <giulio.zizzo@yahoo.co.uk>
Co-authored-by: Beat Buesser <49047826+beat-buesser@users.noreply.github.com>
Signed-off-by: GiulioZizzo <giulio.zizzo@yahoo.co.uk>
Co-authored-by: Beat Buesser <49047826+beat-buesser@users.noreply.github.com>
Signed-off-by: GiulioZizzo <giulio.zizzo@yahoo.co.uk>
Co-authored-by: Beat Buesser <49047826+beat-buesser@users.noreply.github.com>
Signed-off-by: GiulioZizzo <giulio.zizzo@yahoo.co.uk>
Signed-off-by: GiulioZizzo <giulio.zizzo@yahoo.co.uk>
Signed-off-by: GiulioZizzo <giulio.zizzo@yahoo.co.uk>
@lgtm-com
Copy link

lgtm-com bot commented May 13, 2022

This pull request introduces 2 alerts when merging f6b4f91 into 67fa652 - view on LGTM.com

new alerts:

  • 2 for Module is imported more than once

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 @GiulioZizzo Thank you very much!

@beat-buesser beat-buesser merged commit 6d98749 into Trusted-AI:dev_1.10.2 May 14, 2022
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.

Randomised Smoothing Noise Addition Bug
3 participants