from defense.base import defense
[docs]class ft_sam(defense):
r'''Enhancing Fine-Tuning Based Backdoor Defense with Sharpness-Aware Minimization
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. for each round sample a clean batch from given clean subset:
a. do weight perturb to maximize L constrained by rho
b. do outer minimization
5. test the result and get ASR, ACC, RC
.. code-block:: python
parser = argparse.ArgumentParser(description=sys.argv[0])
ft_sam.add_arguments(parser)
args = parser.parse_args()
ft_sam_method = ft_sam(args)
result = ft_sam_method.defense(args.result_file)
.. Note::
@InProceedings{Zhu_2023_ICCV,
author = {Zhu, Mingli and Wei, Shaokui and Shen, Li and Fan, Yanbo and Wu, Baoyuan},
title = {Enhancing Fine-Tuning Based Backdoor Defense with Sharpness-Aware Minimization},
booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
month = {October},
year = {2023},
pages = {4466-4477}}
Args:
baisc args: in the base class
rho(float): Rho parameter for SAM.
adaptive(bool): True if you want to use the Adaptive SAM.
label_smoothing(float): Use 0.0 for no label smoothing.
rho_max(float): max of Rho parameter for SAM.
rho_min(float): min of Rho parameter for SAM.
alpha(float): alpha parameter for gradient_decompose part of SAM.
checkpoint_path(str): specify the checkpoint
'''