IntelLabs / MART

Modular Adversarial Robustness Toolkit
BSD 3-Clause "New" or "Revised" License
16 stars 0 forks source link

Add gradient monitor callback #144

Closed dxoigmn closed 1 year ago

dxoigmn commented 1 year ago

What does this PR do?

This adds a gradient monitor callback so that one can make monitor the norm of different gradients.

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.

Before submitting

Did you have fun?

Make sure you had fun coding 🙃

mzweilin commented 1 year ago

Do you have an example? I tried to run this command, but I didn't see gradient logs in Tensorboard.

CUDA_VISIBLE_DEVICES=0 \
python -m mart \
experiment=CIFAR10_CNN_Adv \
fit=false \
trainer=gpu \
+trainer.limit_test_batches=1 \
+callbacks@model.modules.input_adv_test.callbacks=gradient_monitor \
+model.modules.input_adv_test.callbacks.gradient_monitor.frequency=1

Update: patch and example in #164

dxoigmn commented 1 year ago

There are no parameters in an Adversary ;) This is why I think it's better to modify the state_dict rather than playing tricks by hiding parameters in lists.

mzweilin commented 1 year ago

There are no parameters in an Adversary ;) This is why I think it's better to modify the state_dict rather than playing tricks by hiding parameters in lists.

Resolved in #160