This PR simplifies the abstraction of Adversary by moving adversary.perturber into adversary.composer.perturber
A Composer is a module that generates perturbed input from the benign input and the perturbation. The perturbation is the weights of the Composer module. Perturber is an object to manage the perturbation (e.g. initialization, projection) and return perturbation for Composer to work on.
A universal adversary should be able to use a Composer in the same way.
In the future, we may try to better integrate components in Perturber, such as Initializer and Projector, into Composer directly. For example, the image initializer should be implemented in Composer instead, so that we can easily constrain Lp bound on perturbation.
Type of change
Please check all relevant options.
[ ] Improvement (non-breaking)
[ ] Bug fix (non-breaking)
[ ] New feature (non-breaking)
[x] 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.
What does this PR do?
This PR simplifies the abstraction of
Adversary
by movingadversary.perturber
intoadversary.composer.perturber
A
Composer
is a module that generates perturbed input from the benign input and the perturbation. The perturbation is the weights of theComposer
module.Perturber
is an object to manage the perturbation (e.g. initialization, projection) and return perturbation forComposer
to work on.A universal adversary should be able to use a
Composer
in the same way.In the future, we may try to better integrate components in
Perturber
, such asInitializer
andProjector
, intoComposer
directly. For example, the image initializer should be implemented inComposer
instead, so that we can easily constrain Lp bound on perturbation.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
CUDA_VISIBLE_DEVICES=0 python -m mart experiment=CIFAR10_CNN_Adv trainer=gpu trainer.precision=16
reports 70% (21 sec/epoch).CUDA_VISIBLE_DEVICES=0,1 python -m mart experiment=CIFAR10_CNN_Adv trainer=ddp trainer.precision=16 trainer.devices=2 model.optimizer.lr=0.2 trainer.max_steps=2925 datamodule.ims_per_batch=256 datamodule.world_size=2
reports 70% (14 sec/epoch).Before submitting
pre-commit run -a
command without errorsDid you have fun?
Make sure you had fun coding 🙃