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

trojanNN question about the neuron selection #105

Closed
CHR-ray opened this issue Mar 3, 2022 · 10 comments
Closed

trojanNN question about the neuron selection #105

CHR-ray opened this issue Mar 3, 2022 · 10 comments

Comments

@CHR-ray
Copy link

CHR-ray commented Mar 3, 2022

In the original paper, the author say that "we pick the neuron that has the largest value of the sum of absolute weights ..."

But in trojannn.py, line 116 : "return weight.argsort(descending=False)[:self.neuron_num]" use the ascending order, is this a typo? or you reverse the sequence in other line?

@ain-soph
Copy link
Owner

ain-soph commented Mar 3, 2022

Definitely a bug. Let me fix it and retest the performance locally.

ain-soph added a commit that referenced this issue Mar 3, 2022
ain-soph added a commit that referenced this issue Mar 3, 2022
fix trojannnn neuron selection #105
@ain-soph
Copy link
Owner

ain-soph commented Mar 3, 2022

Actually I don't see any clear performance difference. Well, it's now fixed.

Command I use:

CUDA_VISIBLE_DEVICES=0 python examples/backdoor_attack.py --color --verbose 1 --pretrained --validate_interval 1 --epochs 10 --lr 0.01 --mark_random_init --attack trojannn --tqdm

Try the new tqdm I implemented yesterday!

image

@ain-soph
Copy link
Owner

ain-soph commented Mar 3, 2022

Just to clarify, in case you didn't notice.
We have docs at https://ain-soph.github.io/trojanzoo/trojanvision/attacks/backdoor.html#trojanvision.attacks.TrojanNN

@CHR-ray
Copy link
Author

CHR-ray commented Mar 3, 2022 via email

@ain-soph
Copy link
Owner

ain-soph commented Mar 3, 2022

  1. No, we don't implement reverse engineering training data, because we are measuring many attacks using the same BadNet problem setting. (I may implement that in the future.)
  2. That might because we are currently using resnet18, which is different from VGGface that has multiple FC layers.

I've consulted the original author Yingqi Liu days ago to confirm:

  1. During neuron index selection, conv layer weights (*, *, KH, KW) shall be averaged for the last 2 dimensions.
  2. They don't test ResNet architectures.

@ain-soph
Copy link
Owner

ain-soph commented Mar 3, 2022

Reflection Backdoor is implemented by others. I'll check it today, update codes and write docs.

And could you illustrate the problem in more details?

Btw, there is another 3rd party implementation from Tsinghua group:
https://github.com/THUYimingLi/BackdoorBox/blob/main/core/attacks/Refool.py

@ain-soph
Copy link
Owner

ain-soph commented Mar 3, 2022

@CHR-ray I just checked the original Caffe implementation of TrojanNN.

It seems they don't follow Algorithm 1 to generate their triggers:

  1. They don't follow the cost definition to update input trigger. They actually assign one_hot gradient to the intermediate feature map and directly conduct the backward. It's not relevant to target_value (=100) in paper.
  2. There is no denoise in paper algorithm 1, but exists in the code. (there is denoise in paper algorithm 2 though)

@CHR-ray
Copy link
Author

CHR-ray commented Mar 4, 2022 via email

@ain-soph
Copy link
Owner

ain-soph commented Mar 4, 2022

I will deal with Reflection Backdoor later.

TrojanNN issue should have been solved.
I've followed original author's caffe codes to update the preprocess algorithm. They are now almost equivalent, and I have commented all differences in the code.

You may search Original in the file to see things I've abandoned because there is no performance difference.

https://github.com/ain-soph/trojanzoo/blob/main/trojanvision/attacks/backdoor/trojannn.py

@ain-soph
Copy link
Owner

@CHR-ray Just want to tell you that reflection backdoor is already reimplemented and docs are finished as well.

It is tested and the performance is good,

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