Closed LeavesLei closed 3 years ago
Hi @LeavesLei. Thanks for spotting this!
In fact, the sp_margin.append(adv_perts.cpu().view([-1, np.prod(inputs.shape[1:])]).norm(dim=[1]))
should be indented once, in order to get inside the for inputs, targets in dataloader:
loop.
I just pushed an updated version that fixes this issue. Let me know if you still think that something is problematic!
Thanks for your quick reply😄.
https://github.com/LTS4/hold-me-tight/blob/b893e97f0b5fe8100472ac68d715d0cb99d0c7dc/utils.py#L166
Hi, the work "Hold me tight!" is excellent and I enjoy the reading. Here, I have a small question about the code:
You define
adv_perts
throughadv_perts = torch.zeros_like(inputs)
, and then calculate the perturbations byadv_perts[n], _, _, _, _ = subspace_deepfool(im, model, trans, Sp=Sp)
. However, you re-defineadv_perts
in the next loop without dealing with the calculatedadv_perts[n]
. I am a little confused about this and look forward to your reply.