Coder Social home page Coder Social logo

Comments (4)

ain-soph avatar ain-soph commented on May 23, 2024

This is Ren Pang (♂). Here is the method that generates black/white triggers for ESB attack. Basically, for 3*3 pixel triggers, it generates all combinations (select_point pixels are black, others are white). Shuffle them and pick the first (num_classes + 1) triggers to train the small classifier (the auxiliary 1 is the class of clean data). After training, all classes will be embedded with their unique triggers.

The mark_path argument passed to Watermark class will be ignored, since ESB requires its unique watermark settings. In paper, we compare ESB and other attacks under same transparency and trigger size.

def synthesize_training_sample(self, all_point: int = None, select_point: int = None):
all_point = all_point or self.all_point
select_point = select_point or self.select_point
if 2**all_point < self.model.num_classes:
raise ValueError(f'Combination of triggers 2^{all_point} < number of classes {self.model.num_classes} !')
combination_list = []
for i in range(all_point):
if len(combination_list) >= self.model.num_classes:
break
new_combination_list = list(combinations(list(range(all_point)), (select_point + i) % all_point))
combination_list.extend(new_combination_list)
np.random.seed(env['seed'])
np.random.shuffle(combination_list)
x = torch.ones(len(combination_list), all_point, dtype=torch.float)
for i, idx in enumerate(combination_list):
x[i][list(idx)] = 0.0
y = list(range(len(combination_list)))
return x, y

But to note that, even though ESB in current repo works already, I'm currently preparing codes and docs for TrojanZoo publication in EuroS&P. ESB is not finished yet and it will surely get changed. Upon your request, I may work on it today and hopefully finish the docs and new codes.

from trojanzoo.

ain-soph avatar ain-soph commented on May 23, 2024

And another thing you may feel interested, the original author of ESB previously complained to me about the low successful rate on transparent trigger cases. He proposed that I should change the training process to make it work, but I haven't applied his suggestion yet. See #46 for more details.

from trojanzoo.

ain-soph avatar ain-soph commented on May 23, 2024

Please ignore all previous replies and read the new docs:

https://ain-soph.github.io/trojanzoo/trojanvision/attacks/backdoor.html#trojanvision.attacks.TrojanNet

from trojanzoo.

ain-soph avatar ain-soph commented on May 23, 2024

@5RJ I'll close this issue if you have got things solved.
The updated TrojanNet docs should have a clear illustration.

You may click [source] to jump to corresponding codes on GitHub.

Feel free to reopen the issue and ask me questions.

from trojanzoo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.