首页
/ 开源项目 `poisoning-benchmark` 使用教程

开源项目 `poisoning-benchmark` 使用教程

2024-09-27 08:57:47作者:廉皓灿Ida

1. 项目的目录结构及介绍

poisoning-benchmark/
├── models/
├── poison_crafting/
├── poison_examples/
├── poison_setup/
├── pretrained_models/
├── .gitignore
├── LICENSE.txt
├── README.md
├── benchmark_all.sh
├── benchmark_results_table.py
├── benchmark_test.py
├── how_to.md
├── learning_module.py
├── poison_test.py
├── requirements.txt
├── test_model.py
├── tinyimagenet_module.py
└── train_model.py

目录结构介绍

  • models/: 存放模型文件的目录。
  • poison_crafting/: 存放数据中毒攻击的生成代码。
  • poison_examples/: 存放中毒样本的示例。
  • poison_setup/: 存放中毒设置的配置文件。
  • pretrained_models/: 存放预训练模型的目录。
  • .gitignore: Git 忽略文件配置。
  • LICENSE.txt: 项目许可证文件。
  • README.md: 项目说明文档。
  • benchmark_all.sh: 批量运行基准测试的脚本。
  • benchmark_results_table.py: 生成基准测试结果表格的脚本。
  • benchmark_test.py: 运行单次基准测试的脚本。
  • how_to.md: 使用指南文档。
  • learning_module.py: 学习模块脚本。
  • poison_test.py: 测试中毒样本的脚本。
  • requirements.txt: 项目依赖库配置文件。
  • test_model.py: 测试模型的脚本。
  • tinyimagenet_module.py: TinyImageNet 数据集处理模块。
  • train_model.py: 训练模型的脚本。

2. 项目的启动文件介绍

benchmark_all.sh

这是一个批量运行基准测试的脚本。通过运行该脚本,可以对多个中毒样本批次进行基准测试。

bash benchmark_all.sh <path_to_directory_with_100_batches>

benchmark_test.py

这是一个运行单次基准测试的脚本。通过该脚本,可以对单个中毒样本批次进行基准测试。

python benchmark_test.py --poisons_path <path_to_poison_directory> --dataset <dataset>

poison_test.py

这是一个测试中毒样本的脚本。通过该脚本,可以对中毒样本进行测试。

python poison_test.py --model <model> --model_path <model_path> --poisons_path <path_to_poisons_dir>

3. 项目的配置文件介绍

requirements.txt

该文件列出了项目运行所需的 Python 依赖库。通过以下命令安装依赖库:

pip install -r requirements.txt

learning_module.py

该文件中包含了对 TinyImageNet 数据集的处理配置。需要根据实际数据集路径修改以下配置:

TINYIMAGENET_ROOT = "/fs/cml-datasets/tiny_imagenet"

poison_setup/

该目录下存放了中毒设置的配置文件,包括 poison_setups_transfer_learning.picklepoison_setups_from_scratch.pickle,分别用于迁移学习和从头训练的中毒设置。

pretrained_models/

该目录下存放了预训练模型文件。需要将下载的预训练模型文件放入该目录中。

通过以上介绍,您可以更好地理解和使用 poisoning-benchmark 项目。

登录后查看全文
热门项目推荐