generated from ashleve/lightning-hydra-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Hide adversarial parameters from model checkpoint. #150
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dxoigmn
approved these changes
Jun 1, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
dxoigmn
added a commit
that referenced
this pull request
Jun 1, 2023
* Make Perturber a standard nn.Module. * Move GradientModifier from Perturber to Adversary. * Hide Adversary parameters from model checkpoint. (#150) --------- Co-authored-by: Weilin Xu <weilin.xu@intel.com>
mzweilin
added a commit
that referenced
this pull request
Jun 8, 2023
* Remove NoAdversary * Remove NoAdversary from CIFAR10 adversarial training * Remove NoAdversary from RetinaNet model * Fix COCO_TorchvisionFasterRCNN_Adv experiment * Remove NoAdversary tests * First stab at treating adversary as LightningModule * style * bugfix * Integrate Perturber into LitPerturber * Integrate objective to LitPerturber * Cleanup use of objective function to compute gain * bugfix * Make adversarial trainer silent * style * Move threat model into LitPerturber * Make attack callbacks plain PL callbacks * comment * Remove Perturber * comment * Better silence * Integrate LitPerturber into Adversary * Uncombine Adversary into Adversary and LitPerturber * cleanup * Move silence into utils * bugfix * bugfix * cleanup * Enable dependency injection on Adversary * Make dependency injection backwards compatible * Replace max_iters with trainer.limit_train_batches * comments * Move perturbation creation into initializer * Add Default projector * bugfix * comment * Move gradient modifier into PL hook * Use on_train_epoch_start in favor of initialize_parameters * Make perturbation lazy * Disable logger in attack * Revert initializer to d33658f * cleanup * on_before_optimizer_step -> configure_gradient_clipping * comments * Disable attack progress bar * comments * comments * comments * cleanup * comments * cleanup * comments * comment * Move LitPerturber into perturber.py * bugfix * Make gradient modifiers in-place operations * cleanup * Mark initializers __call__ as no_grad instead of using .data * Mark projectors __call__ as no_grad instead of using .data * Cleanup attack configs * Fix merge error * Fix merge error * comment * Make Enforcer accept **kwargs. * Update test_gradient. * LitPerturber -> Perturber * cleanup * Add _reset functionality * Update tests and fix a bug * Remove batch tests * style * Late bind trainer to input device * fix visualizer test * bugfix * bugfix * disable progress bar * bugfix * Add loss to object detection outputs * comment * Make Adversary and Perturber tuple-aware * comment * Update tests and fix bug * style * Remove BatchEnforcer and BatchComposer * Revert to old gain functionality * Revert change to enforcer * fix perturber tests to take gain * cleanup * Place Trainer on same device as Perturber * Make composer, enforcer and projector tuple aware * fix projector tests * Gracefully fail when input is a dict * Make Projector batch aware * Update projector tests * Fix Adversary gradient test * Make attacker a property * Fix configuration to construct Perturber * Remove MaskAdditive * Revert "Remove MaskAdditive" This reverts commit d0ae325. * cleanup * Undelete * Merge Perturber into Adversary * Update projector test to use proper spec * Abstract Perturber again * bugfix * Smarter configure_perturbation * Make perturbations proper parameters and cleanup Initializer * Cleanup GradientModifier * Cleanup Composer * Cleanup Projector * Cleanup Enforcer * Cleanup callbacks * Cleanup NormalizedAdversaryAdapter * Cleanup MartToArtAttackAdapter * Smarter detection of when we need to create perturbation * cleanup * style * Remove GradientModifier from Perturber and cleanup * bugfix * Add GradientModifier to LitModular * Adversary consumes a OptimizerFactory * Better Composer and Projector type logic * spelling * bugfix * Replace tuple with Iterable[torch.Tensor] * cleanup * Fix tests * Cleanup * Make GradientModifier accept Iterable[torch.Tensor] * Revert changes to LitModular * Revert Adversary consumes a OptimizerFactory * Remove Callback base * Fix tests * bugfix * bugfix * style * Make attack callbacks normal callbacks * Add gradient monitor callback * bugfix * Fix annotations * Make Perturber more flexible * bugfix * Add GradientModifier and fix tests * Fix configs * Get adversary tests from adversary_as_lightningmodule * Make attack callbacks normal callbacks * Move attack optimizers to optimizers * bugfix * style * comment * fix test * style * style * Perturber is no longer a callback * fix tests * fix tests * fix tests * fix tests * fix tests * fix tests * fix tests * bugfix * bugfix * fix tests * add missing tests * return tests to original tests * style * Set optimizer to maximize in attacks * Revert "Set optimizer to maximize in attacks" This reverts commit 41eb387. * Adversary optimizer maximizes gain * Move Composer from Perturber and into Attacker * cleanup * bugfix * Add Composer to Adversary * cleanup * projector -> projector_ * Hide adversarial parameters from model checkpoint. (#150) * Fix merge error * Pin numpy to 1.23.5 due to torch/tensorboard compatibility issue * Make the Adversary Trainer accept loggers. --------- Co-authored-by: Cory Cornelius <cory.cornelius@intel.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Hides adversary parameters from model checkpoint.
Depends on #146
Type of change
Please check all relevant options.
Testing
Please describe the tests that you ran to verify your changes. Consider listing any relevant details of your test configuration.
pytest
python -m mart experiment=CIFAR10_CNN_Adv trainer=gpu
achieves 70% accuracy.Before submitting
pre-commit run -a
command without errorsDid you have fun?
Make sure you had fun coding 🙃