Coder Social home page Coder Social logo

elliothe / bfa Goto Github PK

View Code? Open in Web Editor NEW
30.0 30.0 10.0 2.68 MB

Pytorch implementation of Bit-Flip based adversarial weight Attack (BFA)

Home Page: https://elliothe.github.io/BFA/

License: Other

Shell 0.63% Python 6.72% Jupyter Notebook 92.65%

bfa's People

Contributors

elliothe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bfa's Issues

Error when running resnet18

When I was trying to perform the attacks on resnet18, I modified the model in BFA_imagenet.sh to resnet18, and got the following errors:

Traceback (most recent call last):
  File "main.py", line 860, in <module>
    main()
  File "main.py", line 445, in main
    random_attack=args.random_bfa)
  File "main.py", line 592, in perform_attack
    attack_log = attacker.progressive_bit_search(model, data, target)
  File "/home/yecheng/repo/BFA/attack/BFA.py", line 124, in progressive_bit_search
    key=operator.itemgetter(1))[0]
ValueError: max() arg is an empty sequence

I also tried the other Github repo for your previous paper, however, the issue persists.

May I get some help?

BFA can't equal attack performance in vgg11-bn-quan.

Hello, I tested BFA attack in this code but can't equal attack performance in vgg11-bn-quan, unlike resnet. (N_flips is 11 on paper, but 50 on test this code).

I think that the attack performance gap is caused by using different pre-trained weights.

So, plz uploaded your pre-trained vgg11-bn-quan weight?

don't same attack performance result BFA paper(resnet44 and resnet 56)

I show that attack performance differs from BFA papers while attempting resnet44 and resnet56 BFA Attack. (paper resnet44 8bit is [6, 10, 11, 13, 22] but my resnet44 8bit is [57, 56, 59, 62, 60] and not drop acc 10%)

Therefore, I think BFA attack performance doesn't come out properly when the network gets deeper, what do you think?

Also, if possible, can you provide the weight parameter you used?

my resnet44 and resnet56 training script is this is this.
`
model=resnet56_quan
dataset=cifar10
epochs=160
train_batch_size=128
test_batch_size=128
optimizer=SGD
quan_bitwidth=8
seed=1
label_info=train

save_path=./save/${DATE}/${dataset}${model}${epochs}${optimizer}${label_info}${quan_bitwidth}${seed}
tb_path=${save_path}/tb_log #tensorboard log path

############### Neural network ############################
{
/usr/bin/env python ./main.py --dataset ${dataset}
--data_path ${data_path}
--arch ${model} --save_path ${save_path}
--quan_bitwidth ${quan_bitwidth}
--manualSeed ${seed}
--epochs ${epochs} --learning_rate 0.1
--optimizer ${optimizer}
--schedule 80 120 --gammas 0.1 0.1
--attack_sample_size ${train_batch_size}
--test_batch_size ${test_batch_size}
--workers 4 --ngpu 1 --gpu_id 0
--print_freq 100 --decay 0.0003 --momentum 0.9
} &

model=resnet44_quan
dataset=cifar10
epochs=160
train_batch_size=128
test_batch_size=128
optimizer=SGD
quan_bitwidth=8
seed=1
label_info=train

save_path=./save/${DATE}/${dataset}${model}${epochs}${optimizer}${label_info}${quan_bitwidth}${seed}
tb_path=${save_path}/tb_log #tensorboard log path

############### Neural network ############################
{
/usr/bin/env python ./main.py --dataset ${dataset}
--data_path ${data_path}
--arch ${model} --save_path ${save_path}
--quan_bitwidth ${quan_bitwidth}
--manualSeed ${seed}
--epochs ${epochs} --learning_rate 0.1
--optimizer ${optimizer}
--schedule 80 120 --gammas 0.1 0.1
--attack_sample_size ${train_batch_size}
--test_batch_size ${test_batch_size}
--workers 4 --ngpu 1 --gpu_id 0
--print_freq 100 --decay 0.0003 --momentum 0.9
} &

Error: correct_k = correct[:k].view(-1).float().sum(0)

File "main.py", line 860, in
main()
File "main.py", line 445, in main
random_attack=args.random_bfa)
File "main.py", line 572, in perform_attack
attacker.criterion, log, summary_output=True)
File "main.py", line 770, in validate
prec1, prec5 = accuracy(output.data, target, topk=(1, 5))
File "main.py", line 835, in accuracy
correct_k = correct[:k].view(-1).float().sum(0)
RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

mismatching bin_resnet_cifar

The bin_resnet_cifar code present in the corresponding model folder seems to be quantization resnet rather than bin_resnet_cifar.

Can i refer to bin_vgg that convert to NN from quantized to binarized ?

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.