question for l2 distance in l2_attack
ZekunStevenZhang opened this issue · comments
hey, i found when calculating the l2 distance in loss function of l2 attack, the following code is implemented:
self.l2dist= tf.reduce_sum(tf.square(self.newimg-(tf.tanh(self.timg) * self.boxmul + self.boxplus)),[1,2,3])
since the input data had already normalized between [-0.5,0.5], why applying tanh function to input image again here? why not just use
self.newimg - self.timg
Some code uses [0,1] or [0,255]. This code allows for other cases.
Some code uses [0,1] or [0,255]. This code allows for other cases.
but in this sentence:
imgs = np.arctanh((imgs - self.boxplus) / self.boxmul * 0.999999) # arctanh(2*imgs)
, if imgs is between [0,1], 2*imgs will be between [0,2], but the input of arctanh must be between [-1,1], this will result in errors