-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Reference for image clipping in image recreation step? #70
Comments
Hey, it is already scaled between 0 and 1. The reason for those lines is to force values that become higher than 1 (white color in image domain) and less than 0 (black color in image domain) to be within those ranges. Otherwise it can't be converted to an image. |
Sorry, but I am still confused. Your method: What I thought: I am missing an explanation of why one method makes more sense than the other and would be grateful for a pointer. :) I bet your method is correct, but I wonder what speaks against the other method and would like to hear your thoughts about this. :) So in my mind you think about the tensor being an "image" at all times and clip at the end of the optimization process, to be able to display the output. I rather thought that the tensor could optimize the way it wants and not think about it as an image during the process. I simply "convert" it back to an image range when it is done. |
So, in the beginning there are no negative values in the image because the values are between [0, 255], from here we normalize to the range [0, 1] by dividing 255. I think with this part you have no issue. Now, lets say there is this tensor that we are optimizing/modifying/generating. It can be that the values become less than 0 or more than 1. Now, the problem is, how are we going to convert this to an image? 1- Let's say, we have following values in the tensor: 2- Something like this: Following the same example: Now, again, all values are between [0,1] and output image is [0, 0.217, 0.13, 0.826, 1] * 255. Which method is correct? You can make arguments for both. The reason I use (1) is because in that one, there is less modification to the original tensor. You see, the second one modifies every value in the tensor by definition. You can also argue that by using (1) the scaling is not correct, but in my experience for visualization cases, it really doesn't matter. This is because the values that are less than 0 or bigger than 1 are less and bigger by a veeeeeery small margin, so using (2) and (1) doesn't really change anything. However, if you are talking about adversarial examples, by modifying every pixel during scaling you lose a important properties of adversarial attacks (which is the reason I continued using scaling in this way after working so long with adversarial attacks). This is my reason for using (1) instead of (2). Feel free to use anything. Try it yourself and see if it makes a large difference. I hope this makes things clear now. |
Thanks! |
Glad I could help. I don't have a specific paper for scaling and adversariality, it is mostly my experience and what heard from other researchers during discussion. I vaguely remember reading something about box constraints etc. from Nicholas Carlini though https://nicholas.carlini.com/papers. Take care. |
Hi,
first of all, thanks for providing this repository! I really like it and compare it to my own implementation, trying to understand the algorithms. I am very new to this, so sorry if this is a stupid question, but could you/anyone point me to a reference of why you clip instead of normalizing the images during the recreation phase?
The specific code lines are the following in the
mis_functions.py
:Why shouldn't we rescale them to a range between 0 and 1?
Thanks :)
The text was updated successfully, but these errors were encountered: