Source code for defense.clp

'''
This file is modified based on the following source:
link : https://github.com/rkteddy/channel-Lipschitzness-based-pruning.
The defense method is called clp.

The update include:
    1. data preprocess and dataset setting
    2. model setting
    3. args and config
    4. save process
    5. new standard: robust accuracy
    6. draw the corresponding images of asr and acc according to different proportions
basic sturcture for defense method:
    1. basic setting: args
    2. attack result(model, train data, test data)
    3. clp defense:
        a. prune the model depend on the estimate of TAC
    4. test the result and get ASR, ACC, RC with regard to the chosen threshold and interval
'''

from defense.base import defense



[docs]class clp(defense): r"""Data-free backdoor removal based on channel lipschitzness basic structure: 1. config args, save_path, fix random seed 2. load the backdoor test data 3. load the backdoor attack model 4. clp defense: a. prune the model depend on the estimate of TAC 5. test the result and get ASR, ACC, RC with regard to the chosen threshold and interval .. code-block:: python parser = argparse.ArgumentParser(description=sys.argv[0]) clp.add_arguments(parser) args = parser.parse_args() clp_method = clp(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 = clp_method.defense(args.result_file) .. Note:: @inproceedings{zheng2022data, title={Data-free backdoor removal based on channel lipschitzness}, author={Zheng, Runkai and Tang, Rongjun and Li, Jianze and Liu, Li}, booktitle={European Conference on Computer Vision}, pages={175--191}, year={2022}, organization={Springer}} Args: baisc args: in the base class u (float): the threshold of channel lipschitzness u_min (float): the minimum value of u u_max (float): the maximum value of u u_num (float): the number of u """