Bug in WaNET attack
Closed this issue · 2 comments
Hi, this is some amazing work and is really helpful for people just starting out. I think I might have found a bug and wanted to let you know.
In attacks -> WaNET.py -> add_trigger(self, img, noise=False)
- If there is noise, the grid is calculated as: grid = self.grid + ins / self.h
- However, in the next line grid is recalculated as: grid = torch.clamp(self.grid + ins / self.h, -1, 1)
Im also attaching an image
Hi, this is some amazing work and is really helpful for people just starting out. I think I might have found a bug and wanted to let you know.
In attacks -> WaNET.py -> add_trigger(self, img, noise=False)
- If there is noise, the grid is calculated as: grid = self.grid + ins / self.h
- However, in the next line grid is recalculated as: grid = torch.clamp(self.grid + ins / self.h, -1, 1)
Im also attaching an image
Hi, AcronRK,
Thanks for using our toolbox and nice words. In general, I would say it is not a bug but a code redundancy. Specifically, the torch.clamp is to ensure that all elements are within [-1, 1]. Unless we have a misunderstanding about the range of grid, it should work well. But as I said, there is a redundancy, I think you can delete the line 'grid = self.grid + ins / self.h' and also run the code with the same results.
Anyway, thanks for your notification!
Ah thank you for the clarification :)