- caffe
Get into a dataset dict, such as backdoor/mnist
.
python select*.py
Get the array/file of the index of neurons' activation
, and the array/file of the corresponding weight
sequence of that index. Pick an index for trigger generation.
Modify the path in setting.py
and params, especially neuron
and layer
, in gen_ad.sh
, then run:
bash gen_ad.sh
and get the trigger.
python filter.py
Attach the trigger image to the clean data in order to get the poisoned data.
-
First, run
python load_data.py
, transform the image to pickle file. -
For single-trigger and single-target scheme.Run
retrain.py
to retrain the benign neural network with the combined clean and poisoned datasets to obtain the backdoored model.- To change the target label, modify
inpersonate
in funcload_data_trend()
.
- To change the target label, modify
-
For multi-location retraining, refer to
mnist/mul_location_datahandler.py
;For multi-trigger retraining, refer tomnist/mul_trigger_datahandler.py
. Then, update the code inretrain.py
to poison test data andfilter.py
for training data. -
Run
python read_caffe_param.py read
to get the layer params stored in the pkl file;python read_caffe_param.py save
to get the caffemodel file from pkl file. -
Run
PA.py
to get models' prediction accuracy with clean test data; andASR.py
to check the backdoored models' Attack Success Rate with poisoned data.
- For
Badnets
, we generate random trigger and obey the following steps - For
Hidden-Trigger
, we refer to: UMBCvision/Hidden-Trigger-Backdoor-Attacks.
-
Pruning
- We prune a certain
proportion
of neurons in the convolution layer and test PA and ASR after pruning.
- We prune a certain
-
NeuralCleanse
-
NC codes refer to: bolunwang/backdoor.
-
Some of our models are
channel_first
, but the source codes are only forchannel_last
model. Therefore, we provide the corresponding modified version. -
The source code relies on
tensorflow-gpu==1.10.1
, which is out-of-date. Thus we usetensorflow-gpu==2.4.0
, and modify the code inutils_backdoor.py
. -
gtsrb_visualize_example.py
is the sample code for the cifar10 dataset
-
-
ABS
- ABS codes refer to: naiyeleo/ABS.
- Our image processing method is shown in
preprocess.py
.
-
Strip
- STRIP source codes refer to:garrisongys/STRIP.