sarathknv / adversarial-examples-pytorch

Implementation of Papers on Adversarial Examples
385 stars 78 forks source link

Test with the reprocessed image #1

Open WeicongChen opened 5 years ago

WeicongChen commented 5 years ago

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.

sarathknv commented 5 years ago

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

On Wed, Dec 12, 2018, 8:56 AM juicecwc notifications@github.com 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 .

WeicongChen commented 5 years ago

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
sarathknv commented 5 years ago

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.