DSE-MSU / DeepRobust

A pytorch adversarial library for attack and defense methods on images and graphs
MIT License
995 stars 192 forks source link

requires_grad of adversarial data #36

Open liushunyu opened 4 years ago

liushunyu commented 4 years ago

When I debug the PGDtraining, I find that requires_grad of adversarial data is true.

Is that right? The input image may be not allowed to require grad.

https://github.com/DSE-MSU/DeepRobust/blob/9ba3751f33f87d0eda281497ce84aa99fe1f2206/deeprobust/image/defense/pgdtraining.py#L143

The requires_grad of data_adv is true.

YaxinLi0-0 commented 4 years ago

I think we have to set requires_grad = True to calculate the gradient of loss for the input image.

liushunyu commented 4 years ago

I think if you set requires_grad = True, you will back propagation gradient twice, because the adv image can also be back propagation to the network which generate it.