• 【Adversarial Robustness Toolbox (ART)】对抗性防御工具


    对抗性鲁棒性工具集 ART

    用于机器学习安全性的Python库。ART 由
    Linux Foundation AI & Data Foundation (LF AI & Data)。 ART提供的工具可
    帮助开发人员和研究人员针对以下方面捍卫和评估机器学习模型和应用程序:
    逃逸,数据污染,模型提取和推断的对抗性威胁。ART支持所有流行的机器学习框架
    (TensorFlow,Keras,PyTorch,MXNet,scikit-learn,XGBoost,LightGBM,CatBoost,GPy等),所有数据类型
    (图像,表格,音频,视频等)和机器学习任务(分类,物体检测,语音识别,
    生成模型,认证等)。

    代码阅读

    ├─attacks
    │  ├─evasion
    │  │  ├─adversarial_patch  
    │  │  ├─adversarial_texture
    │  │  ├─feature_adversaries
    │  │  ├─graphite
    │  │  ├─imperceptible_asr  
    │  │  ├─laser_attack       
    │  │  ├─over_the_air_flickering
    │  │  └─projected_gradient_descent
    │  ├─extraction
    │  ├─inference
    │  │  ├─attribute_inference
    │  │  ├─membership_inference
    │  │  ├─model_inversion
    │  │  └─reconstruction
    │  └─poisoning
    │      ├─backdoor_attack_dgm
    │      ├─bad_det
    │      ├─hidden_trigger_backdoor
    │      └─perturbations
    ├─defences
    │  ├─detector
    │  │  ├─evasion
    │  │  │  └─subsetscanning
    │  │  └─poison
    │  ├─postprocessor
    │  ├─preprocessor
    │  │  ├─cutmix
    │  │  ├─cutout
    │  │  └─mixup
    │  ├─trainer
    │  └─transformer
    │      ├─evasion
    │      └─poisoning
    ├─estimators
    │  ├─certification
    │  │  ├─deep_z
    │  │  ├─derandomized_smoothing
    │  │  │  ├─ablators
    │  │  │  └─vision_transformers
    │  │  ├─interval
    │  │  ├─object_seeker
    │  │  └─randomized_smoothing
    │  │      ├─macer
    │  │      ├─smooth_adv
    │  │      └─smooth_mix
    │  ├─classification
    │  ├─encoding
    │  ├─gan
    │  ├─generation
    │  ├─object_detection
    │  ├─object_tracking
    │  ├─poison_mitigation
    │  │  ├─neural_cleanse
    │  │  └─strip
    │  ├─regression
    │  └─speech_recognition
    ├─evaluations
    │  └─security_curve
    ├─experimental
    │  └─estimators
    │      └─classification
    ├─metrics
    │  └─privacy
    └─preprocessing
        ├─audio
        │  └─l_filter
        ├─expectation_over_transformation
        │  ├─image_center_crop
        │  ├─image_rotation
        │  └─natural_corruptions
        │      ├─brightness
        │      ├─contrast
        │      ├─gaussian_noise
        │      ├─shot_noise
        │      └─zoom_blur
        ├─image
        │  ├─image_resize
        │  └─image_square_pad
        └─standardisation_mean_std
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81

    config

    指定类型

    ART_DATA_PATH: str
    
    • 1

    文件访问控制

    _folder = os.path.expanduser("~")
    if not os.access(_folder, os.W_OK):  # pragma: no cover
        _folder = "/tmp"  # pylint: disable=C0103
    _folder = os.path.join(_folder, ".art")
    
    • 1
    • 2
    • 3
    • 4

    在Python中,global语句用于指示一个变量是全局变量,而不是局部变量。当pylint检测到global语句的使用时,它会引发警告W0603,因为使用全局变量有时会导致代码更难理解和维护。

    通过添加# pylint: disable=W0603作为注释,你指示pylint忽略与ART_DATA_PATH变量的global语句相关的警告。这样,你的代码可以通过linting检查而不会引发该特定警告。

    def set_data_path(path):
        """
        Set the path for ART's data directory (ART_DATA_PATH).
        """
        expanded_path = os.path.abspath(os.path.expanduser(path))
        os.makedirs(expanded_path, exist_ok=True)
        if not os.access(expanded_path, os.R_OK):  # pragma: no cover
            raise OSError(f"path {expanded_path} cannot be read from")
        if not os.access(expanded_path, os.W_OK):  # pragma: no cover
            logger.warning("path %s is read only", expanded_path)
    
        global ART_DATA_PATH  # pylint: disable=W0603
        ART_DATA_PATH = expanded_path
        logger.info("set ART_DATA_PATH to %s", expanded_path)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    attack

    abc.ABCMeta是Python中abc模块提供的一个元类(metaclass)。

    • abc:它代表"Abstract Base Classes",是Python标准库中提供的一个模块,用于定义抽象基类(Abstract Base Classes)和接口。
    • ABCMeta:它是abc模块中的一个元类。元类是一个用于定义其他类行为的类。在这种情况下,ABCMeta用于定义抽象基类。

    抽象基类是不能直接实例化的类,它们作为子类的蓝图。它们定义了一个共同的接口,可以包含必须由子类实现的抽象方法。

    通过继承ABCMeta并将其作为元类在类定义中使用,您可以定义一个抽象基类。这样可以强制子类遵循特定的行为或契约要求,确保它们实现了特定的方法或符合特定的接口。

    class InputFilter(abc.ABCMeta):  # pragma: no cover
    class Attack(abc.ABC):
    
    • 1
    • 2
  • 相关阅读:
    【教程】PyTorch Timer计时器
    Python的优点和缺点
    Log4j发布2.17.0,解决2.16.0存在的DOS攻击风险
    【POJ No. 3368】 最频繁值 Frequent values
    [SWPUCTF 2023 秋季新生赛]——Web方向 详细Writeup
    只出现一次的数字
    2022春季数据结构期末考试总结
    华为机试 - 简易内存池
    bat 批量删除文件名中特定字符
    npm证书过期问题
  • 原文地址:https://blog.csdn.net/prinTao/article/details/134283245