Coder Social home page Coder Social logo

Comments (6)

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

Hi, is there any concern that you don't want to directly adjust batch_size in dataset?

from trojanzoo.

TDteach avatar TDteach commented on May 25, 2024

There is a misunderstanding.
I set the batch_size through the parameters to the program, however, calc_grad function takes the whole x as an integration meaning that the batch_size I set is useless in calc_grad.

from trojanzoo.

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

Sorry I don’t catch your idea. x is fetched from dataloader with (N, C, H, W) where N is the batch size.

You need to set batch size to make N smaller. We don’t need to further split x.
calc_grad only process one batch of data, and it doesn't use batch_size in this method for sure.

Btw, what’s the scenario? are you testing PGD or BadNet attack that uses PGD optimizer?

from trojanzoo.

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

Will close this issue if there is no further response.

from trojanzoo.

TDteach avatar TDteach commented on May 25, 2024

The following is the running shell that induces the OOM problem

python examples/backdoor_attack.py --verbose 1 --dataset cifar10 --model resnet101_comp --attack clean_label --train_mode dataset --poison_percent 0.25 --batch_size 32 --pretrain  --epoch 100 --save

Below is the line-116 of trojanvision/attacks/backdoor/clean_label.py

poison_imgs, _ = self.pgd.optimize(_input_poison_imgs)

This line gives the _input directly the poison_imgs (using the above shell, with shape of [1250,3,32,32]).
However, neither the optimize function in trojanvision/shortcut/pgd.py nor the optimize function in trojanvision/optim/pgd.py has no action to split the _input , making OOM error for resnet101 such big network on machines with limited GPU memory

from trojanzoo.

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

Ok, I get your idea. Clean Label attack use pgd attack for poison generation with one single batch. But if the poison ratio is too large which leads to the large batch size, it will be out of memory when using a large resnet101 model.

I’ll fix it by using a tensor dataset.

But just to note that, resnet101 is an overkill for Cifar10. So it is for the 0.25 poison ratio.

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.