detection_pretrain.beatrix
- class beatrix(args)[source]
Bases:
defense
The Beatrix Resurrections: Robust Backdoor Detection via Gram Matrices
basic sturcture for defense method:
basic setting: args
attack result(model, train data, test data)
- Beatrix detection:
extract features of clean samples.
extract features of poisoned samples.
analyze features by Gram Matrices.
measure deviations and compute the threshold.
detect poisoned samples by threshold.
compute TPR and FPR
parser = argparse.ArgumentParser(description=sys.argv[0]) beatrix.add_arguments(parser) args = parser.parse_args() beatrix_method = beatrix(args) if "result_file" not in args.__dict__: args.result_file = 'defense_test_badnet' elif args.result_file is None: args.result_file = 'defense_test_badnet' result = beatrix_method.detection(args.result_file)
Note
- @article{ma2022beatrix,
title={The” Beatrix’’Resurrections: Robust Backdoor Detection via Gram Matrices}, author={Ma, Wanlun and Wang, Derui and Sun, Ruoxi and Xue, Minhui and Wen, Sheng and Xiang, Yang}, journal={arXiv preprint arXiv:2209.11715}, year={2022}}
- Parameters:
args (baisc) – in the base class
target_layer (str) – which layer for detection