defense.ft
- class ft[source]
Bases:
defense
Basic class for ft defense method.
basic structure:
config args, save_path, fix random seed
load the backdoor attack data and backdoor test data
load the backdoor model
- ft defense:
get some clean data
retrain the backdoor model
test the result and get ASR, ACC, RC
parser = argparse.ArgumentParser(description=sys.argv[0]) ft.add_arguments(parser) args = parser.parse_args() ft_method = ft(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 = ft_method.defense(args.result_file)
- Parameters:
args (baisc) – in the base class
ratio (float) – the ratio of clean data loader
index (str) – index of clean data