This PR adds functions to Composer so that we can compose a Composer with a sequence of Functions. One use case is that we can reuse the Mask and Additive functions to compose a MaskAdditive Composer.
Add the mart.attack.composer.Function base class and three children classes Additive, Mask and Overlay.
Add Composer(functions:dict) so it is configurable in Hydra.
Add Function(order:int) so we can sort the sequence of Functions in Composer.
Update existing configs.
Update tests.
Type of change
Please check all relevant options.
[ ] Improvement (non-breaking)
[ ] Bug fix (non-breaking)
[x] 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.
What does this PR do?
This PR adds
functions
toComposer
so that we can compose aComposer
with a sequence ofFunctions
. One use case is that we can reuse theMask
andAdditive
functions to compose aMaskAdditive
Composer.mart.attack.composer.Function
base class and three children classesAdditive
,Mask
andOverlay
.Composer(functions:dict)
so it is configurable in Hydra.Function(order:int)
so we can sort the sequence ofFunction
s inComposer
.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 🙃