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

Error occurs when using patches_universal #6

Open
WillBuyingFrog opened this issue Jul 24, 2022 · 3 comments
Open

Error occurs when using patches_universal #6

WillBuyingFrog opened this issue Jul 24, 2022 · 3 comments

Comments

@WillBuyingFrog
Copy link

Hello,
The error argument 'size' (position 1) must be tuple of ints, not Tensor always occur at 60% progress of the funciton attack_single_run() when I tried to run the code with the following command:

CUDA_VISIBLE_DEVICES=0 python eval.py \
	--norm=patches_universal --model=pt_vgg \
	--n_queries=100000 --alpha_init=0.3 \
	--data_path=../frogdata/ILSVRC2012_val --k=2500 \
	--n_ex=30 --targeted --target_class=530

Where ../frogdata/ILSVRC2012_val is the path to the imagenet validation set.

The error reports is like:
sparse-rs-issue

I used the latest stable version of PyTorch at first. Then I tried to switch to PyTorch 1.8.0 and Python3.8.5 according to README.md in the repository, but that doesn't help, so I decided to post an issue here to seek for help.

Thank you for your fascinating work and any help given!

@fra31
Copy link
Owner

fra31 commented Jul 24, 2022

Hi,

thanks for interest in our work! I think it's sufficient to modify

new_clr = self.random_choice(new_clr).clone().clamp(0., 1.)
to

new_clr = self.random_choice(new_clr.shape).clone().clamp(0., 1.)

If this solves your issue, I'll update the code too. Thanks for letting me know!

@WillBuyingFrog
Copy link
Author

Thank you for your help! The program runs smoothly after 60% of attack_single_run().

Unfortunately, when attack_single_run() returns, it still reports error:
patch_universal_issues

It seems that n_queries is not defined in patches_universalpart of the code. I tried to add the following line of code after line 538 like what frames_universal implements:

n_queries = torch.ones_like(y).float()

After I added the code, the programs runs ok. The only concern is that the changes I made probably doesn't match the paper's algorithm(actually I'm quite new to research and I may miss something when reading papers). Could you please check my changes mentioned above?

Thank you again for your help!

@fra31
Copy link
Owner

fra31 commented Jul 25, 2022

I think it should be fine, for the universal attacks all queries should anyway be used for all points i.e. there's no early stopping. I'll update that as well, thanks!

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

No branches or pull requests

2 participants