MART icon indicating copy to clipboard operation
MART copied to clipboard

Inputs should be between [0-1]

Open dxoigmn opened this issue 2 years ago • 2 comments

Right now MART assumes inputs are between [0-255]. This is a fine choice for 8-bit images, however, as we move towards multi-modal inputs like 24-bit depth, it might be better to assume that inputs are 32-bit floats between [0-1]? I suppose that [0-1] is arbitrary but a lot of existing tools already assume this anyway.

dxoigmn avatar Feb 09 '23 01:02 dxoigmn

One reason to use the [0, 255] input range is numeric stability.

The Enforcer would complain if I switch to [0,1] input.

$ python -m mart experiment=CIFAR10_CNN_Adv fit=false
...
  File "/home/weilinxu/coder/MART/mart/attack/enforcer.py", line 65, in verify
    norm_vals = perturbation.norm(p=self.p, dim=self.dim, keepdim=self.keepdim)
mart.attack.enforcer.ConstraintViolated: L-inf norm of perturbation exceeds 0.00784313725490196, reaching 0.007843166589736938

If we want to use the traditional [0,1] range in datamodule, we can add a feature in Adversary that converts input to the [0,255] space and convert the output back to [0,1]. So that we get both compatibility and numeric stability.

mzweilin avatar Jun 30 '23 00:06 mzweilin

We should really be using torch.isclose anyways.

dxoigmn avatar Jun 30 '23 01:06 dxoigmn