defense.ep
- class ep[source]
Bases:
defense
Pre-activation Distributions Expose Backdoor Neurons
basic structure:
config args, save_path, fix random seed
load the backdoor attack data and backdoor test data
- ep defense:
calculate the entropy of each norm layer
prune the model depend on the mask
test the result and get ASR, ACC, RC
parser = argparse.ArgumentParser(description=sys.argv[0]) ep.add_arguments(parser) args = parser.parse_args() ep_method = ep(args) if "result_file" not in args.__dict__: args.result_file = 'one_epochs_debug_badnet_attack' elif args.result_file is None: args.result_file = 'one_epochs_debug_badnet_attack' result = ep_method.defense(args.result_file)
Note
@article{zheng2022pre, title={Pre-activation Distributions Expose Backdoor Neurons}, author={Zheng, Runkai and Tang, Rongjun and Li, Jianze and Liu, Li}, journal={Advances in Neural Information Processing Systems}, volume={35}, pages={18667–18680}, year={2022}}
- Parameters:
args (baisc) – in the base class
u (float) – the u in the ep defense
u_min (float) – the default minimum value of u
u_max (float) – the default maximum value of u
u_num (float) – the default number of u
- Update:
All threshold evaluation results will be saved in the save_path folder as a picture, and the selected fixed threshold model results will be saved to defense_result.pt