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

Correct f-strings in parallel and non-parallel metadata #2549

Closed
wants to merge 1 commit into from

Conversation

lockwoodar
Copy link
Collaborator

@lockwoodar lockwoodar commented Jan 3, 2025

Description

Full Issue Details: #2548

  • Fixes string literals in returned AutoAttack metadata (both parallel and non-parallel) to correctly use f-strings

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

  • I utilized the same test that is outlined in Erroneous literal string in AutoAttack metadata #2548
  • I corrected the f-strings locally and built a local wheel for ART-Core, which was then installed
  • I repeated the testing to assert that the metadata returned correctly uses the f-string substitution
>>> attack_noparallel = AutoAttack(estimator=ptc, attacks=attacks, targeted=True, parallel_pool_size = 0)
>>> attack_parallel = AutoAttack(estimator=ptc, attacks=attacks, targeted=True, parallel_pool_size = pool)
>>>
>>>
>>> no_parallel_adv = attack_noparallel.generate(x=x_train, y=y_train)
>>> parallel_adv = attack_parallel.generate(x=x_train, y=y_train)
>>> print(repr(attack_noparallel))
AutoAttack(targeted=True, parallel_pool_size=0, num_attacks=1)
BestAttacks:
image 1: ProjectedGradientDescentPyTorch(norm=inf, eps=0.1, eps_step=0.1, targeted=True, num_random_init=0, batch_size=32, minimal=False, summary_writer=None, decay=None, max_iter=10, random_eps=False, verbose=False, )
image 2: ProjectedGradientDescentPyTorch(norm=inf, eps=0.1, eps_step=0.1, targeted=True, num_random_init=0, batch_size=32, minimal=False, summary_writer=None, decay=None, max_iter=10, random_eps=False, verbose=False, )
image 3: ProjectedGradientDescentPyTorch(norm=inf, eps=0.1, eps_step=0.1, targeted=True, num_random_init=0, batch_size=32, minimal=False, summary_writer=None, decay=None, max_iter=10, random_eps=False, verbose=False, )
image 4: n/a
image 5: n/a
image 6: n/a
image 7: n/a
image 8: ProjectedGradientDescentPyTorch(norm=inf, eps=0.1, eps_step=0.1, targeted=True, num_random_init=0, batch_size=32, minimal=False, summary_writer=None, decay=None, max_iter=10, random_eps=False, verbose=False, )
image 9: ProjectedGradientDescentPyTorch(norm=inf, eps=0.1, eps_step=0.1, targeted=True, num_random_init=0, batch_size=32, minimal=False, summary_writer=None, decay=None, max_iter=10, random_eps=False, verbose=False, )
image 10: n/a
>>>
>>>
>>> print(repr(attack_parallel))
AutoAttack(targeted=True, parallel_pool_size=15, num_attacks=10)
BestAttacks:
image 1: ProjectedGradientDescentPyTorch(norm=inf, eps=0.1, eps_step=0.1, targeted=True, num_random_init=0, batch_size=32, minimal=False, summary_writer=None, decay=None, max_iter=10, random_eps=False, verbose=False, )
image 2: ProjectedGradientDescentPyTorch(norm=inf, eps=0.1, eps_step=0.1, targeted=True, num_random_init=0, batch_size=32, minimal=False, summary_writer=None, decay=None, max_iter=10, random_eps=False, verbose=False, )
image 3: ProjectedGradientDescentPyTorch(norm=inf, eps=0.1, eps_step=0.1, targeted=True, num_random_init=0, batch_size=32, minimal=False, summary_writer=None, decay=None, max_iter=10, random_eps=False, verbose=False, )
image 4: n/a
image 5: n/a
image 6: n/a
image 7: n/a
image 8: ProjectedGradientDescentPyTorch(norm=inf, eps=0.1, eps_step=0.1, targeted=True, num_random_init=0, batch_size=32, minimal=False, summary_writer=None, decay=None, max_iter=10, random_eps=False, verbose=False, )
image 9: ProjectedGradientDescentPyTorch(norm=inf, eps=0.1, eps_step=0.1, targeted=True, num_random_init=0, batch_size=32, minimal=False, summary_writer=None, decay=None, max_iter=10, random_eps=False, verbose=False, )
image 10: n/a
>>>

Test Configuration:
OS = Ubuntu 22.04.4 LTS
Python version = 3.11
ART version or commit number = 1.19.0
PyTorch version = 2.3.1

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

Copy link

codecov bot commented Jan 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.40%. Comparing base (27e4c81) to head (6d0fa9c).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2549      +/-   ##
==========================================
- Coverage   85.41%   85.40%   -0.02%     
==========================================
  Files         334      334              
  Lines       31001    31001              
  Branches     5300     5300              
==========================================
- Hits        26481    26476       -5     
- Misses       3053     3056       +3     
- Partials     1467     1469       +2     
Files with missing lines Coverage Δ
art/attacks/evasion/auto_attack.py 86.15% <ø> (ø)

... and 3 files with indirect coverage changes

@lockwoodar
Copy link
Collaborator Author

lockwoodar commented Jan 3, 2025

In the process of trying to correct the missing --signoff, I apparently put this pull request into a bad state. Closing and starting from a clean fork to avoid having a complicated commit history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant