cmhcbb / attackbox

MIT License
57 stars 27 forks source link

Logging of distortion #1

Open w-garcia opened 4 years ago

w-garcia commented 4 years ago

Hello,

I am working through your implementation of the OPT attack, and had a question about calculation of distortion. It is logged as only g_theta here: https://github.com/cmhcbb/attackbox/blob/master/attack/OPT_attack.py#L69

However if I understand correctly, the right way to log distortion would be as LA.norm(g_theta * best_theta), since the final adversarial sample is x0 + g_theta*best_theta. It is printed that way here: https://github.com/cmhcbb/attackbox/blob/master/attack/OPT_attack.py#L99

Could this be clarified by the authors?

Thanks

cmhcbb commented 4 years ago

Hi, https://github.com/cmhcbb/attackbox/blob/de692afc5db5c76b5d6a641c56df1d4dd052a463/attack/OPT_attack.py#L69 This line is pointing to the first iteration of log, i.e. the distortion after finding the initial points by adding random distortion. The log records all iteration's distortion and its # of quires until the algorithm stops, so you could think it is a matrix per example as shown in https://github.com/cmhcbb/attackbox/blob/de692afc5db5c76b5d6a641c56df1d4dd052a463/attack/OPT_attack.py#L152.

Also, the best_theta is always a norm-1 vector so we don't need to calculate the norm again.