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 customizable summary writer and indicators of attack failure #1416

Merged
merged 29 commits into from
Dec 14, 2021

Conversation

beat-buesser
Copy link
Collaborator

@beat-buesser beat-buesser commented Nov 21, 2021

Description

This pull request introduces a new Summary Writer API which allows to collect metrics based on attack and estimator properties as function of iteration step in TensorBoard format. It provides a default summary writer collecting properties of loss gradients, loss values, adversarial patch, and indicators of attack failure. This summary writer will be available in all attacks in art.attacks as property self.summary_writer and selected attacks including Projected Gradient Descent and Adversarial Patch and Texture have been updated accordingly, more attacks will follow soon. Users can provide customized summary writers to the attacks to collect custom metrics. Introduces a new Union type ESTIMATOR_TYPE representing all estimators in ART.

Fixes #1325

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

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

Beat Buesser added 3 commits November 12, 2021 22:29
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
@beat-buesser beat-buesser self-assigned this Nov 21, 2021
@beat-buesser beat-buesser added the enhancement New feature or request label Nov 21, 2021
@beat-buesser beat-buesser added this to Pull request open in ART 1.9.0 via automation Nov 21, 2021
@beat-buesser beat-buesser added this to the ART 1.9.0 milestone Nov 21, 2021
@beat-buesser beat-buesser linked an issue Nov 21, 2021 that may be closed by this pull request
@codecov-commenter
Copy link

codecov-commenter commented Nov 21, 2021

Codecov Report

Merging #1416 (5d493c0) into dev_1.9.0 (b77725e) will increase coverage by 8.76%.
The diff coverage is 76.19%.

Impacted file tree graph

@@              Coverage Diff              @@
##           dev_1.9.0    #1416      +/-   ##
=============================================
+ Coverage      81.65%   90.42%   +8.76%     
=============================================
  Files            236      237       +1     
  Lines          19214    19386     +172     
  Branches        3387     3438      +51     
=============================================
+ Hits           15690    17530    +1840     
+ Misses          2815     1076    -1739     
- Partials         709      780      +71     
Impacted Files Coverage Δ
art/utils.py 90.92% <ø> (+1.03%) ⬆️
art/estimators/object_tracking/pytorch_goturn.py 72.24% <6.25%> (-3.82%) ⬇️
...ion/adversarial_patch/adversarial_patch_pytorch.py 83.18% <50.00%> (+70.96%) ⬆️
.../adversarial_patch/adversarial_patch_tensorflow.py 81.81% <50.00%> (+68.22%) ⬆️
...adient_descent/projected_gradient_descent_numpy.py 87.50% <60.00%> (-1.66%) ⬇️
...ient_descent/projected_gradient_descent_pytorch.py 96.96% <60.00%> (-1.46%) ⬇️
...escent/projected_gradient_descent_tensorflow_v2.py 96.03% <60.00%> (-1.49%) ⬇️
art/attacks/evasion/fast_gradient.py 84.00% <71.42%> (-0.55%) ⬇️
art/attacks/attack.py 92.98% <80.00%> (+1.31%) ⬆️
...adversarial_texture/adversarial_texture_pytorch.py 88.37% <80.00%> (-0.66%) ⬇️
... and 32 more

@beat-buesser beat-buesser changed the title Implement customizable summary writer and indicators of attack failue Implement customizable summary writer and indicators of attack failure Nov 21, 2021
Beat Buesser added 5 commits November 22, 2021 23:12
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
Beat Buesser and others added 5 commits December 7, 2021 23:00
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
Copy link
Collaborator

@ambrishrawat ambrishrawat left a comment

Choose a reason for hiding this comment

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

Please find comments in the code

@@ -458,24 +461,20 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> T
for images, target, mask_i in dataset:
_ = self._train_step(images=images, target=target, mask=mask_i)

# Write summary
if self.summary_writer is not None: # pragma: no cover
Copy link
Collaborator

Choose a reason for hiding this comment

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

the attack constructors accept “bool” for summary writer, how does that flow work here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, the super class replace any input type with an instance of SummaryWriter or None.

global_step=global_step,
)

# Attack Failure Indicators
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are these failure indicator based on some paper? Is it possible to include information here for documentation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great suggestion, I will add the reference to Pintor et al. (https://arxiv.org/abs/2106.09947)

TENSORFLOWV2_ESTIMATOR_TYPE = Union[ # pylint: disable=C0103
TensorFlowV2Classifier,
TensorFlowV2Estimator,
]

ESTIMATOR_TYPE = Union[ # pylint: disable=C0103
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are the changes in utils.py independent of SummaryWriter? Maybe include an additional line in the PR description?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They are related, but I'll also update the PR description.

yield x_train_mnist[:n_train], y_train_mnist[:n_train], x_test_mnist[:n_test], y_test_mnist[:n_test]


def test_update(art_warning, fix_get_mnist_subset, image_dl_estimator):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should there be a separate test case for boolean values of swd?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea, I'll add additional tests.

Beat Buesser added 7 commits December 8, 2021 20:50
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
Copy link
Collaborator

@ambrishrawat ambrishrawat left a comment

Choose a reason for hiding this comment

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

Looks good, thanks

Beat Buesser added 4 commits December 10, 2021 17:32
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
@lgtm-com
Copy link

lgtm-com bot commented Dec 11, 2021

This pull request introduces 1 alert when merging c2c33fa into b77725e - view on LGTM.com

new alerts:

  • 1 for Module is imported more than once

Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
@lgtm-com
Copy link

lgtm-com bot commented Dec 13, 2021

This pull request introduces 3 alerts when merging b91bad1 into b77725e - view on LGTM.com

new alerts:

  • 3 for Module is imported more than once

Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
@lgtm-com
Copy link

lgtm-com bot commented Dec 14, 2021

This pull request introduces 3 alerts when merging c28a1b3 into b77725e - view on LGTM.com

new alerts:

  • 3 for Module is imported more than once

Signed-off-by: Beat Buesser <beat.buesser@ie.ibm.com>
@lgtm-com
Copy link

lgtm-com bot commented Dec 14, 2021

This pull request introduces 3 alerts when merging 5d493c0 into b77725e - view on LGTM.com

new alerts:

  • 3 for Module is imported more than once

@beat-buesser beat-buesser merged commit c114a49 into dev_1.9.0 Dec 14, 2021
ART 1.9.0 automation moved this from Pull request open to Pull request done Dec 14, 2021
@beat-buesser beat-buesser deleted the development_issue_1325 branch December 14, 2021 14:45
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.9.0
  
Pull request done
Development

Successfully merging this pull request may close these issues.

integrate "indicators of attack failure" from Pintor et al 2021
3 participants