adversarial-examples-pytorch icon indicating copy to clipboard operation
adversarial-examples-pytorch copied to clipboard

Test with the reprocessed image

Open WeicongChen opened this issue 5 years ago • 3 comments

Hi, great repo!

I am little confused with this line https://github.com/sarathknv/adversarial-examples-pytorch/blob/54887aa583ee19e94fc95e23684271019eecdd68/fgsm.py#L84 As far as I know, it is more reasonable to test with the reprocessed image rather than inp.

WeicongChen avatar Dec 12 '18 03:12 WeicongChen

By 'reprocessed image' do you mean image with preprocessing undone?

On Wed, Dec 12, 2018, 8:56 AM juicecwc [email protected] wrote:

Hi, great repo!

I am little confused with this line

https://github.com/sarathknv/adversarial-examples-pytorch/blob/54887aa583ee19e94fc95e23684271019eecdd68/fgsm.py#L84 As far as I know, it is more reasonable to test with the reprocessed image rather than inp.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sarathknv/adversarial-examples-pytorch/issues/1, or mute the thread https://github.com/notifications/unsubscribe-auth/AQ59I3mu4eJOTlNGoc_kW7QM9cmw7Erpks5u4HdigaJpZM4ZOqdc .

sarathknv avatar Dec 12 '18 03:12 sarathknv

No, what I mean is the adversarial image. Better viewed in the following code.

adv = inp.data.cpu().numpy()[0]
adv = adv.transpose(1, 2, 0)
adv = (adv * std) + mean
adv = np.clip(adv, 0, 1)
adv = (adv - mean) / std # this is what i mean

WeicongChen avatar Dec 12 '18 04:12 WeicongChen

You are clipping the adversarial image before inputting to the model, so that after undoing preprocessing it is within the [0 255] bound. Yeah, this is sensible.

sarathknv avatar Dec 20 '18 09:12 sarathknv