Skip to content
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

Inputs should be between [0-1] #70

Open
dxoigmn opened this issue Feb 9, 2023 · 2 comments
Open

Inputs should be between [0-1] #70

dxoigmn opened this issue Feb 9, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@dxoigmn
Copy link
Contributor

dxoigmn commented Feb 9, 2023

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 dxoigmn added the enhancement New feature or request label Feb 9, 2023
@dxoigmn dxoigmn mentioned this issue Jun 22, 2023
14 tasks
@mzweilin
Copy link
Contributor

mzweilin commented Jun 30, 2023

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.

@dxoigmn
Copy link
Contributor Author

dxoigmn commented Jun 30, 2023

We should really be using torch.isclose anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants