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

Implement CutMix in Numpy, PyTorch, and TensorFlow #1910

Merged
merged 8 commits into from
Nov 29, 2022

Conversation

f4str
Copy link
Collaborator

@f4str f4str commented Nov 12, 2022

Description

Implementation of the CutMix data augmentation defense in the Numpy, PyTorch, and TensorFlow frameworks.

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.

  • Tests for the CutMix preprocessor in Numpy
  • Tests for the CutMix preprocessor in PyTorch
  • Tests for the CutMix preprocessor in PyTorch

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

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>
Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>
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 12, 2022

Codecov Report

Merging #1910 (580a908) into dev_1.13.0 (6e82fe1) will increase coverage by 1.31%.
The diff coverage is 73.36%.

Impacted file tree graph

@@              Coverage Diff               @@
##           dev_1.13.0    #1910      +/-   ##
==============================================
+ Coverage       84.25%   85.57%   +1.31%     
==============================================
  Files             254      257       +3     
  Lines           23661    23890     +229     
  Branches         4289     4340      +51     
==============================================
+ Hits            19935    20443     +508     
+ Misses           2624     2336     -288     
- Partials         1102     1111       +9     
Impacted Files Coverage Δ
art/defences/preprocessor/cutmix/cutmix.py 72.00% <72.00%> (ø)
.../defences/preprocessor/cutmix/cutmix_tensorflow.py 72.36% <72.36%> (ø)
art/defences/preprocessor/cutmix/cutmix_pytorch.py 74.66% <74.66%> (ø)
art/defences/preprocessor/__init__.py 100.00% <100.00%> (ø)
art/attacks/evasion/boundary.py 92.72% <0.00%> (-1.22%) ⬇️
art/estimators/classification/tensorflow.py 84.30% <0.00%> (+0.20%) ⬆️
art/estimators/classification/pytorch.py 86.38% <0.00%> (+0.46%) ⬆️
art/estimators/classification/blackbox.py 98.00% <0.00%> (+2.00%) ⬆️
art/estimators/classification/lightgbm.py 95.00% <0.00%> (+6.66%) ⬆️
art/estimators/scikitlearn.py 75.00% <0.00%> (+8.33%) ⬆️
... and 10 more

@lgtm-com
Copy link

lgtm-com bot commented Nov 12, 2022

This pull request introduces 7 alerts when merging 707bfa8 into c366b1d - view on LGTM.com

new alerts:

  • 3 for Redundant comparison
  • 2 for Module is imported more than once
  • 2 for Non-callable called

@beat-buesser beat-buesser self-requested a review November 14, 2022 11:47
@beat-buesser beat-buesser self-assigned this Nov 14, 2022
@beat-buesser beat-buesser added the enhancement New feature or request label Nov 14, 2022
@beat-buesser beat-buesser added this to Pull request open in ART 1.13.0 via automation Nov 14, 2022
@beat-buesser beat-buesser added this to the ART 1.13.0 milestone Nov 14, 2022
@beat-buesser beat-buesser linked an issue Nov 14, 2022 that may be closed by this pull request
@f4str f4str marked this pull request as draft November 14, 2022 21:01
Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>
@f4str f4str marked this pull request as ready for review November 21, 2022 21:06
Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>
@lgtm-com
Copy link

lgtm-com bot commented Nov 21, 2022

This pull request introduces 5 alerts when merging be08f13 into dcd1fe7 - view on LGTM.com

new alerts:

  • 3 for Redundant comparison
  • 2 for Module is imported more than once

Heads-up: LGTM.com's PR analysis will be disabled on the 5th of December, and LGTM.com will be shut down ⏻ completely on the 16th of December 2022. Please enable GitHub code scanning, which uses the same CodeQL engine ⚙️ that powers LGTM.com. For more information, please check out our post on the GitHub blog.

Signed-off-by: Farhan Ahmed <Farhan.Ahmed@ibm.com>
else:
# NHWC <-- NFHWC
x_aug = np.squeeze(x_nfhwc, axis=1)
elif x_ndim == 5: # lgtm [py/redundant-comparison]

Check warning

Code scanning / CodeQL

Redundant comparison

Test is always true, because of [this condition](1).
# NHWC <-- NCHW <-- NCFHW
x_nchw = torch.squeeze(x_ncfhw, dim=2)
x_aug = torch.permute(x_nchw, (0, 2, 3, 1))
elif x_ndim == 5:

Check warning

Code scanning / CodeQL

Redundant comparison

Test is always true, because of [this condition](1).
else:
# NHWC <-- NFHWC
x_aug = tf.squeeze(x_nfhwc, axis=1)
elif x_ndim == 5:

Check warning

Code scanning / CodeQL

Redundant comparison

Test is always true, because of [this condition](1).
@beat-buesser beat-buesser merged commit caa606c into Trusted-AI:dev_1.13.0 Nov 29, 2022
ART 1.13.0 automation moved this from Pull request open to Pull request done Nov 29, 2022
@f4str f4str deleted the cutmix-implementation branch December 15, 2022 22:49
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.13.0
  
Pull request done
Development

Successfully merging this pull request may close these issues.

Implementation of DP-InstaHide and Data Augmentation Defenses
3 participants