-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is the number of perturbed pixels greater than the specified value k in Sparse-RS algorithm #7
Comments
Hi, I'm not sure to understand what you mean: are you re-implementing the algorithm or just using the available code? As you mentioned, at L315 new pixels are perturbed, but at L313 the same number of perturbed pixels have been reset to the original values (i.e. are now unperturbed) so that the perturbation size is preserved. Hope this helps! |
Thanks for you answer. I mean that it only ensures that the number of perturbed pixels in the current iteration does not exceed eps at L313-L315. However, since the perturbed pixels outside the range [0, eps] at L313 will accumulate with the update For example, the sample Should the code at L305 be changed to |
We have that For patches the perturbations are built differently: the perturbations (the patches and locations) are stored as independent tensors, i.e. not applied on the images. Then, the perturbations are applied at each iteration on a copy of the original images here. Therefore, unlike for L0, |
But the range of [0, eps] is limited. For example, if we set eps=150, we reset 10 pixels the original values, and perturb 10 pixels outside the range of [0, eps] each iteration. We assume that all perturbations outside the range of [0, eps] do not overlap. So in the 16th iteration, we perturbed 160 pixelx, but we can only reset 150 pixelx to the original value at most in the range of [0, eps]. In subsequent iterations, the number of perturbed pixels gets larger and larger, to more than 150. |
The range of [0, eps] just means that at most eps pixels among all the pixels in the image e.g. around 50k for ImageNet are perturbed, doesn't indicate the indices of the pixels which can be perturbed (if that's what you meant). In your example, at each iteration we start with a set A of 150 perturbed pixels (they can be any of the 50k pixels in the image), randomly sample 10 elements of A and reset them to the original value (now only 140 pixels are perturbed), randomly sample 10 pixels which were not in A and perturb them (again 150 pixels perturbed). This preserves the number of perturbed pixels. |
Thank you for your answer, which completely solves my question. |
Hi, I am still having issues replicating your results by following the code.
When we reproduce the code to our framework, we find that the number of perturbed pixels is greater than the specified sparsity value
eps
.Following the implementation of this code, we find a further perturbation on the sample
x_best
when randomly searching for a new sample. At line 315, the algorithm perturbs the samplex_best
outside the range [0, eps] because the parametereps_it
is always larger than 1. Therefore, the number of perturbed pixels is greater thaneps
following the iteration. But according to the paper, the number of perturbed pixels should not exceedeps
.There may be something wrong with my understanding of your code, and I hope for your kindful help.
sparse-rs/rs_attacks.py
Lines 304 to 323 in 21d8759
The text was updated successfully, but these errors were encountered: