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

Cannot change topk value #6

Open
noagarcia opened this issue Oct 2, 2020 · 0 comments
Open

Cannot change topk value #6

noagarcia opened this issue Oct 2, 2020 · 0 comments

Comments

@noagarcia
Copy link

Hi again,

I have found a new problem. The code breaks if I change the topk parameter. For example, the following works well:

python main.py --attack_only --attack_mode q --attack_al sea --fliprate 0 --topk 1 --paraphrase_data val --attacked_checkpoint data/bs256.pth

But if I use 3 instead of 1 in topk:

python main.py --attack_only --attack_mode q --attack_al sea --fliprate 0 --topk 3 --paraphrase_data val --attacked_checkpoint data/bs256.pth

It produces the following error:

--------------------------------------------------
Namespace(adv_delay=10, adv_end=15, advloss_w=1, advtrain=False, advtrain_data='train', alpha=0.5, attack_al='sea', attack_mode='q', attack_only=True, attacked_checkpoint='data/bs256.pth', checkpoint=None, describe='describe your setting', epsilon=0.3, eval_advtrain=False, fliprate=0.0, generate_adv_example=True, iteration=2, lr_decay=15, name=[], paraphrase_data='val', resume=None, samples_frac=1, test_advtrain=False, topk=3, vqacp=False)
--------------------------------------------------
Num obj:  100
Num epochs:  23
Batch size:  256
Model type:  baseline
Optimization Method:  Adamax
Schedule Method:  warm_up
Loss Method:  binary_cross_entropy_with_logits
Clip Value:  0.25
Init LR:  0.001
LR decay step:  2
LR decay rate:  0.25
LR half life:  50000
Normalize visual feature:  False
Print Gradient:  False
Normalize Box Size:  False
Max answer choice:  3129
Manually set max question lenght:  666
Random Seed:  5225
gradual_warmup_steps:  [0.0005, 0.001, 0.0015, 0.002]
Weight Decay:  0.0
--------------------------------------------------
GPU ID 0
Loading model parameters.
Loading model parameters.
Loading model parameters.
Loading model parameters.
sea :   0% 0/838 [00:00<?, ?it/s]Traceback (most recent call last):
  File "main.py", line 74, in <module>
    main()
  File "main.py", line 60, in main
    attackvqa.attack(attackvqa.val_loader)
  File "/home/noa/Projects/seada-vqa/seada/adversarial_vqa.py", line 178, in attack
    v, b, v_mask, q_adv, q_len_adv, q_mask_adv, answer, q_str_adv, image_id_adv, q_id_adv = self.adversarial.perturb((v, b, q, q_str, v_mask, q_mask, image_id, q_id, q_len), y=answer, oripred=clean_logits)
  File "/home/noa/Projects/seada-vqa/seada/attacks.py", line 208, in perturb
    q_len_clue = sorted(q_len_clue, key=lambda x: x[0], reverse=True)
RuntimeError: bool value of Tensor with more than one value is ambiguous
sea :   0% 0/838 [02:05<?, ?it/s]

Any idea why this is happening?

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

1 participant