[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-BorealisAI--advertorch":3,"tool-BorealisAI--advertorch":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":79,"owner_location":79,"owner_email":79,"owner_twitter":80,"owner_website":81,"owner_url":82,"languages":83,"stars":96,"forks":97,"last_commit_at":98,"license":99,"difficulty_score":23,"env_os":100,"env_gpu":101,"env_ram":100,"env_deps":102,"category_tags":111,"github_topics":112,"view_count":23,"oss_zip_url":79,"oss_zip_packed_at":79,"status":16,"created_at":125,"updated_at":126,"faqs":127,"releases":163},4002,"BorealisAI\u002Fadvertorch","advertorch","A Toolbox for Adversarial Robustness Research","AdverTorch 是一个基于 PyTorch 构建的 Python 工具箱，专为对抗鲁棒性研究而设计。在深度学习领域，模型往往容易受到精心设计的“对抗样本”干扰，导致识别错误甚至系统失效。AdverTorch 旨在解决这一安全隐患，为研究人员提供了一套标准化的工具，用于生成对抗扰动、测试防御机制以及进行对抗训练，从而帮助提升 AI 模型在面对恶意攻击时的稳定性与可靠性。\n\n该工具主要面向人工智能领域的开发者与科研人员，特别是那些专注于模型安全、鲁棒性评估及攻防算法研究的团队。其核心亮点在于模块化设计，内置了多种经典的攻击算法（如 LinfPGDAttack）和防御策略，并提供了清晰的脚本示例，让用户能快速复现前沿研究成果或开展新实验。此外，项目保持活跃更新，致力于兼容更多框架与版本。无论是想要验证模型脆弱性的学者，还是希望构建更安全系统的工程师，AdverTorch 都能提供高效、灵活的技术支持，是探索 AI 安全边界的重要助手。","\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fborealisai\u002Fadvertorch\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FBorealisAI_advertorch_readme_18441bee6a71.png\" alt=\"advertorch logo\" width=\"200\">\u003C\u002Fa>\n\n[![Build Status](https:\u002F\u002Ftravis-ci.org\u002FBorealisAI\u002Fadvertorch.svg?branch=master)](https:\u002F\u002Ftravis-ci.org\u002FBorealisAI\u002Fadvertorch)\n\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fborealisai\u002Fadvertorch\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FBorealisAI_advertorch_readme_f1831049eb3b.png\" alt=\"advertorch text\" width=\"100\">\u003C\u002Fa> is a Python toolbox for adversarial robustness research. The primary functionalities are implemented in PyTorch. Specifically, AdverTorch contains modules for generating adversarial perturbations and defending against adversarial examples, also scripts for adversarial training.\n\n\n#### Latest version (v0.2)\n\n## Installation\n\n### Installing AdverTorch itself\n\nWe developed AdverTorch under Python 3.6 and PyTorch 1.0.0 & 0.4.1. To install AdverTorch, simply run\n\n```\npip install advertorch\n```\n\nor clone the repo and run\n```\npython setup.py install\n```\n\nTo install the package in \"editable\" mode:\n```\npip install -e .\n```\n\n### Setting up the testing environments\n\nSome attacks are tested against implementations in [Foolbox](https:\u002F\u002Fgithub.com\u002Fbethgelab\u002Ffoolbox) or [CleverHans](https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Fcleverhans) to ensure correctness. Currently, they are tested under the following versions of related libraries.\n```\nconda install -c anaconda tensorflow-gpu==1.11.0\npip install git+https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Fcleverhans.git@336b9f4ed95dccc7f0d12d338c2038c53786ab70\npip install Keras==2.2.2\npip install foolbox==1.3.2\n```\n\n\n## Examples\n```python\n# prepare your pytorch model as \"model\"\n# prepare a batch of data and label as \"cln_data\" and \"true_label\"\n# ...\n\nfrom advertorch.attacks import LinfPGDAttack\n\nadversary = LinfPGDAttack(\n    model, loss_fn=nn.CrossEntropyLoss(reduction=\"sum\"), eps=0.3,\n    nb_iter=40, eps_iter=0.01, rand_init=True, clip_min=0.0, clip_max=1.0,\n    targeted=False)\n\nadv_untargeted = adversary.perturb(cln_data, true_label)\n\ntarget = torch.ones_like(true_label) * 3\nadversary.targeted = True\nadv_targeted = adversary.perturb(cln_data, target)\n```\n\nFor runnable examples see [`advertorch_examples\u002Ftutorial_attack_defense_bpda_mnist.ipynb`](https:\u002F\u002Fgithub.com\u002FBorealisAI\u002Fadvertorch\u002Fblob\u002Fmaster\u002Fadvertorch_examples\u002Ftutorial_attack_defense_bpda_mnist.ipynb) for how to attack and defend; see [`advertorch_examples\u002Ftutorial_train_mnist.py`](https:\u002F\u002Fgithub.com\u002FBorealisAI\u002Fadvertorch\u002Fblob\u002Fmaster\u002Fadvertorch_examples\u002Ftutorial_train_mnist.py) for how to adversarially train a robust model on MNIST.\n\n## Documentation\n\nThe documentation webpage is on readthedocs  https:\u002F\u002Fadvertorch.readthedocs.io.\n\n\n## Coming Soon\n\nAdverTorch is still under active development. We will add the following features\u002Fitems down the road:\n\n* more examples\n* support for other machine learning frameworks, e.g. TensorFlow\n* more attacks, defenses and other related functionalities\n* support for other Python versions and future PyTorch versions\n* contributing guidelines\n* ...\n\n\n## Known issues\n\n`FastFeatureAttack` and `JacobianSaliencyMapAttack` do not pass the tests against the version of CleverHans used. (They use to pass tests on a previous version of CleverHans.) This issue is being investigated. In the file `test_attacks_on_cleverhans.py`, they are marked as \"skipped\" in `pytest` tests. \n\n## License\n\nThis project is licensed under the LGPL. The terms and conditions can be found in the LICENSE and LICENSE.GPL files.\n\n## Citation\n\nIf you use AdverTorch in your research, we kindly ask that you cite the following [technical report](https:\u002F\u002Farxiv.org\u002Fabs\u002F1902.07623):\n\n```\n@article{ding2019advertorch,\n  title={{AdverTorch} v0.1: An Adversarial Robustness Toolbox based on PyTorch},\n  author={Ding, Gavin Weiguang and Wang, Luyu and Jin, Xiaomeng},\n  journal={arXiv preprint arXiv:1902.07623},\n  year={2019}\n}\n```\n\n\n## Contributors\n\n* [Gavin Weiguang Ding](https:\u002F\u002Fgwding.github.io\u002F)\n* Luyu Wang\n* Xiaomeng Jin\n* Laurent Meunier\n* Alexandre Araujo\n* Jérôme Rony\n* Ben Feinstein\n* Francesco Croce\n* Taro Kiritani\n","\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fborealisai\u002Fadvertorch\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FBorealisAI_advertorch_readme_18441bee6a71.png\" alt=\"advertorch logo\" width=\"200\">\u003C\u002Fa>\n\n[![构建状态](https:\u002F\u002Ftravis-ci.org\u002FBorealisAI\u002Fadvertorch.svg?branch=master)](https:\u002F\u002Ftravis-ci.org\u002FBorealisAI\u002Fadvertorch)\n\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fborealisai\u002Fadvertorch\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FBorealisAI_advertorch_readme_f1831049eb3b.png\" alt=\"advertorch text\" width=\"100\">\u003C\u002Fa> 是一个用于对抗鲁棒性研究的 Python 工具箱。其主要功能基于 PyTorch 实现。具体来说，AdverTorch 包含生成对抗扰动和防御对抗样本的模块，以及用于对抗训练的脚本。\n\n\n#### 最新版本 (v0.2)\n\n## 安装\n\n### 安装 AdverTorch 本身\n\n我们是在 Python 3.6 和 PyTorch 1.0.0 及 0.4.1 的环境下开发 AdverTorch 的。要安装 AdverTorch，只需运行：\n\n```\npip install advertorch\n```\n\n或者克隆仓库并运行：\n```\npython setup.py install\n```\n\n若希望以“可编辑”模式安装该包：\n```\npip install -e .\n```\n\n### 搭建测试环境\n\n部分攻击会与 [Foolbox](https:\u002F\u002Fgithub.com\u002Fbethgelab\u002Ffoolbox) 或 [CleverHans](https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Fcleverhans) 中的实现进行对比测试，以确保正确性。目前，这些测试是在以下相关库的版本下进行的：\n```\nconda install -c anaconda tensorflow-gpu==1.11.0\npip install git+https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Fcleverhans.git@336b9f4ed95dccc7f0d12d338c2038c53786ab70\npip install Keras==2.2.2\npip install foolbox==1.3.2\n```\n\n\n## 示例\n```python\n# 准备好你的 PyTorch 模型，命名为 \"model\"\n# 准备一批数据和标签，分别命名为 \"cln_data\" 和 \"true_label\"\n# ...\n\nfrom advertorch.attacks import LinfPGDAttack\n\nadversary = LinfPGDAttack(\n    model, loss_fn=nn.CrossEntropyLoss(reduction=\"sum\"), eps=0.3,\n    nb_iter=40, eps_iter=0.01, rand_init=True, clip_min=0.0, clip_max=1.0,\n    targeted=False)\n\nadv_untargeted = adversary.perturb(cln_data, true_label)\n\ntarget = torch.ones_like(true_label) * 3\nadversary.targeted = True\nadv_targeted = adversary.perturb(cln_data, target)\n```\n\n更多可运行的示例，请参阅 [`advertorch_examples\u002Ftutorial_attack_defense_bpda_mnist.ipynb`](https:\u002F\u002Fgithub.com\u002FBorealisAI\u002Fadvertorch\u002Fblob\u002Fmaster\u002Fadvertorch_examples\u002Ftutorial_attack_defense_bpda_mnist.ipynb)，了解如何进行攻击与防御；另请参阅 [`advertorch_examples\u002Ftutorial_train_mnist.py`](https:\u002F\u002Fgithub.com\u002FBorealisAI\u002Fadvertorch\u002Fblob\u002Fmaster\u002Fadvertorch_examples\u002Ftutorial_train_mnist.py)，学习如何在 MNIST 数据集上进行对抗训练以构建鲁棒模型。\n\n## 文档\n\n文档网页位于 readthedocs：https:\u002F\u002Fadvertorch.readthedocs.io。\n\n\n## 即将推出的功能\n\nAdverTorch 仍在积极开发中。未来我们将添加以下功能或内容：\n\n* 更多示例\n* 对其他机器学习框架的支持，例如 TensorFlow\n* 更多攻击、防御及其他相关功能\n* 对其他 Python 版本和未来 PyTorch 版本的支持\n* 贡献指南\n* ……\n\n\n## 已知问题\n\n`FastFeatureAttack` 和 `JacobianSaliencyMapAttack` 在当前使用的 CleverHans 版本下无法通过测试。（它们曾在旧版本的 CleverHans 中通过测试。）此问题正在调查中。在 `test_attacks_on_cleverhans.py` 文件中，这两个攻击已被标记为在 `pytest` 测试中“跳过”。\n\n## 许可证\n\n本项目采用 LGPL 许可证。详细条款可在 LICENSE 和 LICENSE.GPL 文件中找到。\n\n## 引用\n\n如果您在研究中使用了 AdverTorch，我们诚挚地请求您引用以下技术报告：\n\n```\n@article{ding2019advertorch,\n  title={{AdverTorch} v0.1: An Adversarial Robustness Toolbox based on PyTorch},\n  author={Ding, Gavin Weiguang and Wang, Luyu and Jin, Xiaomeng},\n  journal={arXiv preprint arXiv:1902.07623},\n  year={2019}\n}\n```\n\n\n## 贡献者\n\n* [Gavin Weiguang Ding](https:\u002F\u002Fgwding.github.io\u002F)\n* 王璐宇\n* 金晓萌\n* 洛朗·梅尼耶\n* 亚历山大·阿拉乌若\n* 杰罗姆·罗尼\n* 本·费因斯坦\n* 弗朗切斯科·克罗切\n* 桃太郎·桐谷","# AdverTorch 快速上手指南\n\nAdverTorch 是一个基于 PyTorch 的 Python 工具箱，专为对抗鲁棒性研究设计。它提供了生成对抗扰动、防御对抗样本以及进行对抗训练的核心模块。\n\n## 环境准备\n\n*   **操作系统**：Linux \u002F macOS \u002F Windows\n*   **Python 版本**：推荐 Python 3.6+\n*   **核心依赖**：PyTorch 1.0.0 或 0.4.1+\n*   **可选依赖（用于测试验证）**：\n    若需与 Foolbox 或 CleverHans 的实现进行对比测试，需安装以下特定版本：\n    ```bash\n    conda install -c anaconda tensorflow-gpu==1.11.0\n    pip install git+https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Fcleverhans.git@336b9f4ed95dccc7f0d12d338c2038c53786ab70\n    pip install Keras==2.2.2\n    pip install foolbox==1.3.2\n    ```\n    > **提示**：国内用户可使用清华或阿里镜像源加速 `pip` 和 `conda` 安装（例如在 pip 命令后添加 `-i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple`）。\n\n## 安装步骤\n\n你可以通过 PyPI 直接安装，或从源码安装。\n\n### 方式一：使用 pip 安装（推荐）\n```bash\npip install advertorch\n```\n*(国内加速)*\n```bash\npip install advertorch -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n```\n\n### 方式二：从源码安装\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fborealisai\u002Fadvertorch.git\ncd advertorch\npython setup.py install\n```\n\n### 方式三：开发者模式安装\n如果你需要修改源码，建议使用可编辑模式安装：\n```bash\npip install -e .\n```\n\n## 基本使用\n\n以下示例展示了如何使用 `LinfPGDAttack` 对 PyTorch 模型生成非定向和定向的对抗样本。\n\n假设你已经准备好了模型 (`model`)、输入数据 (`cln_data`) 和真实标签 (`true_label`)。\n\n```python\nimport torch\nimport torch.nn as nn\nfrom advertorch.attacks import LinfPGDAttack\n\n# 初始化攻击器\nadversary = LinfPGDAttack(\n    model, \n    loss_fn=nn.CrossEntropyLoss(reduction=\"sum\"), \n    eps=0.3,\n    nb_iter=40, \n    eps_iter=0.01, \n    rand_init=True, \n    clip_min=0.0, \n    clip_max=1.0,\n    targeted=False\n)\n\n# 1. 生成非定向对抗样本 (Untargeted Attack)\nadv_untargeted = adversary.perturb(cln_data, true_label)\n\n# 2. 生成定向对抗样本 (Targeted Attack)\n# 设定目标类别为 3\ntarget = torch.ones_like(true_label) * 3\nadversary.targeted = True\nadv_targeted = adversary.perturb(cln_data, target)\n```\n\n更多完整可运行的示例（如 MNIST 上的攻防演练和对抗训练），请参考官方仓库中的 `advertorch_examples` 目录。","某自动驾驶初创公司的算法团队正在研发交通标志识别系统，急需验证模型在面对恶意对抗样本时的鲁棒性，以防止因细微噪声干扰导致误判引发事故。\n\n### 没有 advertorch 时\n- **重复造轮子耗时**：研究人员需手动复现 PGD、FGSM 等经典攻击算法的数学公式与反向传播逻辑，代码调试周期长达数周。\n- **框架兼容困难**：团队基于 PyTorch 构建模型，但许多现有攻防库主要支持 TensorFlow，跨框架迁移不仅易出错且性能难以保证。\n- **评估标准不一**：缺乏统一的扰动生成与防御测试接口，不同成员编写的攻击脚本参数设置混乱，导致实验结果无法横向对比。\n- **对抗训练复杂**：想要通过对抗训练提升模型健壮性，需自行编写复杂的训练循环来动态生成对抗样本并更新权重，极易引入 Bug。\n\n### 使用 advertorch 后\n- **开箱即用高效**：直接调用 `LinfPGDAttack` 等模块，仅需几行代码即可生成高质量对抗样本，将实验验证时间从数周缩短至几小时。\n- **原生 PyTorch 支持**：作为专为 PyTorch 设计的工具箱，完美契合现有计算图结构，无需任何框架转换即可无缝集成到工作流中。\n- **标准化实验流程**：提供统一的攻击与防御 API 接口，团队成员可轻松复用标准化的测试脚本，确保不同实验间的公平性与可复现性。\n- **一键对抗训练**：内置成熟的对抗训练脚本（如 MNIST 示例），帮助团队快速部署鲁棒模型，显著提升了系统在极端噪声下的识别准确率。\n\nadvertorch 将繁琐的底层算法实现转化为标准化的开发组件，让研发团队能专注于核心策略优化而非基础代码构建，极大加速了高鲁棒性 AI 系统的落地进程。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FBorealisAI_advertorch_18441bee.png","BorealisAI","RBC Borealis","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FBorealisAI_ad982e10.jpg","",null,"RBCBorealis","http:\u002F\u002Frbcborealis.com\u002F","https:\u002F\u002Fgithub.com\u002FBorealisAI",[84,88,92],{"name":85,"color":86,"percentage":87},"Jupyter Notebook","#DA5B0B",78,{"name":89,"color":90,"percentage":91},"Python","#3572A5",22,{"name":93,"color":94,"percentage":95},"Shell","#89e051",0,1361,201,"2026-04-04T14:48:22","LGPL-3.0","未说明","非必需。开发环境提及可安装 tensorflow-gpu==1.11.0 用于测试对比，但核心功能基于 PyTorch（支持 CPU 和 GPU），无特定显卡型号或显存大小要求。",{"notes":103,"python":104,"dependencies":105},"核心库基于 PyTorch 1.0.0 或 0.4.1 开发。若需运行与 Foolbox 或 CleverHans 的对比测试，需额外配置特定的旧版 TensorFlow、Keras 及相关库环境。部分攻击算法（FastFeatureAttack 和 JacobianSaliencyMapAttack）在当前版本的 CleverHans 测试中存在已知问题，已被跳过。","3.6",[106,107,108,109,110],"torch>=1.0.0","tensorflow-gpu==1.11.0 (仅测试环境)","cleverhans==336b9f4 (仅测试环境)","keras==2.2.2 (仅测试环境)","foolbox==1.3.2 (仅测试环境)",[13,54],[113,114,115,116,117,118,119,120,121,122,123,124],"pytorch","adversarial-examples","adversarial-example","adversarial-perturbations","adversarial-attacks","adversarial-machine-learning","adversarial-learning","robustness","toolbox","security","machine-learning","benchmarking","2026-03-27T02:49:30.150509","2026-04-06T05:36:28.563888",[128,133,138,143,148,153,158],{"id":129,"question_zh":130,"answer_zh":131,"source_url":132},18227,"使用 L1 PGD 攻击时遇到 CUDA 设备类型不匹配（RuntimeError: expected type torch.cuda.FloatTensor but got torch.FloatTensor）怎么办？","该问题已在 PR #78 中修复。错误原因是 delta 张量未正确移动到 CUDA 设备。虽然手动修改源码将 `.data` 改为 `.data.cuda()` 可以临时解决，但建议直接更新到包含修复的最新版本。对于其他 L2 和 Linf PGD 攻击，通常不需要此修改，因为它们内部处理机制不同。","https:\u002F\u002Fgithub.com\u002FBorealisAI\u002Fadvertorch\u002Fissues\u002F48",{"id":134,"question_zh":135,"answer_zh":136,"source_url":137},18228,"如何限制 CarliniWagnerL2Attack 的扰动在 epsilon 范数球内？CW 攻击与带有 CWLoss 的 PGD 攻击有何区别？","CarliniWagnerL2Attack 旨在显式最小化特定的损失函数（包含扰动项和置信度项），而带有 CWLoss 的 PGD 攻击则是通过迭代地沿梯度符号方向更新来近似这一过程。两者相关但实现方式不同。历史上，CW 攻击通常用于 L2 范数，而 PGD 通常用于 Linf 范数。目前库中尚未对两者在相同 Lp 范数下进行系统性比较，但在评估模型鲁棒性时，可根据具体需求选择：若需严格遵循原始论文优化目标，选 CW 攻击；若需快速迭代或统一框架，可选 PGD with CWLoss。","https:\u002F\u002Fgithub.com\u002FBorealisAI\u002Fadvertorch\u002Fissues\u002F65",{"id":139,"question_zh":140,"answer_zh":141,"source_url":142},18229,"为什么 L2 PGD 攻击使用 `clamp_by_pnorm` 而不是简单的 `batch_clamp`？在 ImageNet 上攻击 ResNet50 失败该如何调整参数？","L2 范数约束需要在整个向量空间中进行投影，而不仅仅是逐元素截断，因此必须使用 `clamp_by_pnorm` 来确保扰动向量的 L2 范数不超过 epsilon，这符合数学定义。相比之下，Linf 攻击可以使用逐元素截断。如果在 ImageNet 上攻击 ResNet50 失败，建议将 `eps` 参数设置为 1.0 作为起点。官方教程笔记本（tutorial_attack_imagenet.ipynb）已更新包含 L2PGDAttack 的示例供参考。","https:\u002F\u002Fgithub.com\u002FBorealisAI\u002Fadvertorch\u002Fissues\u002F39",{"id":144,"question_zh":145,"answer_zh":146,"source_url":147},18230,"当图像经过 Normalize 预处理（均值\u002F标准差归一化）后，数据范围不再是 [0, 1]，如何设置 FGSM 等攻击的 clip_min 和 clip_max？","最佳实践是将数据归一化操作整合到模型本身（即在模型 forward 函数中包含 Normalize 层）。这样，攻击算法接收到的输入仍然是 [0, 1] 范围的原始像素值，攻击过程中的裁剪（clamp）操作可以安全地使用默认的 `clip_min=0.0` 和 `clip_max=1.0`。攻击生成的对抗样本在输入模型前会自动经过归一化。不要尝试计算归一化后的新范围并修改攻击参数，因为这会破坏攻击逻辑。","https:\u002F\u002Fgithub.com\u002FBorealisAI\u002Fadvertorch\u002Fissues\u002F30",{"id":149,"question_zh":150,"answer_zh":151,"source_url":152},18231,"如何实现集成攻击（Ensemble Attacks）？遇到 \"Trying to backward through the graph a second time\" 错误如何解决？","可以通过创建一个继承自 `torch.nn.Module` 的包装类来实现集成攻击，该类在 `forward` 方法中遍历多个模型并平均输出。遇到 \"backward through the graph a second time\" 错误通常是因为在循环中对同一个计算图多次反向传播且未释放中间变量。解决方法包括：1. 确保每次迭代前清空梯度（`optimizer.zero_grad()` 或 `model.zero_grad()`）；2. 如果需要在同一图中多次反向传播，需在第一次调用 `backward()` 时设置 `retain_graph=True`；3. 检查是否在循环外重复使用了涉及计算图的张量。","https:\u002F\u002Fgithub.com\u002FBorealisAI\u002Fadvertorch\u002Fissues\u002F17",{"id":154,"question_zh":155,"answer_zh":156,"source_url":157},18232,"在 MI-FGSM（动量迭代攻击）的实现中，为什么第一步似乎没有考虑初始样本的梯度？","实际上第一步是考虑了梯度的。在代码实现中，扰动 `delta` 初始化为零。当迭代步数 `i==0` 时，计算得到的 `delta.grad` 本质上就是原始图像相对于损失函数的梯度。因为此时 `delta` 为零，反向传播计算的是输入（即原始图像 + 0）的梯度，所以 `delta.grad` 等同于“原始图像的梯度”。随后的动量更新会基于这个初始梯度进行累积。","https:\u002F\u002Fgithub.com\u002FBorealisAI\u002Fadvertorch\u002Fissues\u002F15",{"id":159,"question_zh":160,"answer_zh":161,"source_url":162},18233,"如何使用 advertorch 对 Inception_v1 (GoogLeNet) 模型进行对抗训练？是否需要利用辅助分支（auxiliary branches）？","这取决于测试时是否使用辅助分支。如果测试时包含辅助分支的输出，那么对抗训练时自然也应该包含它们。如果测试时不使用辅助分支，那么是否在训练中使用它们以及权重分配则是一个超参数问题，需要根据实验效果调整。目前库维护者没有针对 Inception 模型对抗训练的具体经验，建议将其视为一个需要调优的实验设置。","https:\u002F\u002Fgithub.com\u002FBorealisAI\u002Fadvertorch\u002Fissues\u002F5",[]]