defense.ft

class ft[source]

Bases: defense

Basic class for ft defense method.

basic structure:

  1. config args, save_path, fix random seed

  2. load the backdoor attack data and backdoor test data

  3. load the backdoor model

  4. ft defense:
    1. get some clean data

    2. retrain the backdoor model

  5. 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