attacks
Foolbox adversarial-attack guidance for selecting fixed-epsilon, minimization, gradient, decision-based, score-based, stochastic, spatial, dataset, EOT, and custom attack workflows.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- attacks
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Foolbox adversarial-attack guidance for selecting fixed-epsilon, minimization, gradient, decision-based, score-based, stochastic, spatial, dataset, EOT, and custom attack workflows.
- disable-model-invocation
- true
02 资源文件 6
- 参考文档references/api-reference.md2.1 KB
- 参考文档references/attack-authoring.md1.3 KB
- 参考文档references/attack-overview.md2.3 KB
- 参考文档references/troubleshooting.md1.8 KB
- 参考文档references/workflows.md2.8 KB
- 脚本scripts/smoke_attacks.py1.5 KB
03 SKILL.md 正文
Foolbox attacks
Use this route when the task is to generate adversarial examples, compare
robust accuracy, choose an attack by threat model, configure criteria or
distances, or implement a new attack. Read
references/attack-overview.md to choose a
family, references/api-reference.md for call
semantics, and references/workflows.md for recipes.
Command path
The scripts/ path below is relative to the generated Foolbox skill root, not
to a native Foolbox checkout and not to the caller's current directory. From
any cwd, use the directory containing the root SKILL.md:
# Replace this non-executable placeholder with the absolute directory containing the root SKILL.md.
export SKILL_ROOT=/path/to/installed/skills/disco/foolbox
cd "$SKILL_ROOT"
Use the actual skill-root path when it differs from this installation. Keep
plots and other generated artifacts in an explicit absolute output directory or
"$SKILL_ROOT/outputs/"; never rely on a plot filename resolving to the native
checkout or overwrite files under references/ or scripts/.
Run an attack safely
- Wrap the model through the
modelsroute, check clean accuracy, and ensure inputs lie inside the declared bounds. - Choose untargeted labels or a
TargetedMisclassificationcriterion. Confirm the concrete attack supports that criterion. - Instantiate the attack with explicit steps for expensive or stochastic
methods. Use
epsilonsas a scalar for one budget or a sequence to compare budgets in one call. - Use
clippedoutputs for visualizing or measuring budgeted adversarials; usesuccessto calculate attack success and robust accuracy. - Report backend, attack class, distance, epsilon(s), steps, clean accuracy, and stochastic/repeat policy. Never compare attack results without stating whether the model and data preprocessing are identical.
Run the helper below for a safe NumPy noise plus DatasetAttack check. Framework gradient attacks require an installed framework and are not proved by the CPU smoke.
cd "$SKILL_ROOT"
python sub-skills/attacks/scripts/smoke_attacks.py --help
python sub-skills/attacks/scripts/smoke_attacks.py
The helper is also linked at scripts/smoke_attacks.py.
Select by threat model
- Fast white-box:
FGSM/FGM,LinfPGD,L2PGD, basic iterative, momentum, Adam-PGD; requires differentiable framework tensors. - Minimization: Carlini-Wagner, EAD, DeepFool, NewtonFool, contrast, blur, BoundaryAttack; choose when the perturbation should be minimized or when the attack owns an early-stop distance.
- Decision/score/black-box: additive/repeated noise, HopSkipJump, BoundaryAttack, Brendel-Bethge, Pointwise, DatasetAttack; use when gradients or probabilities are unavailable.
- Special geometry:
SpatialAttacksearches rotations/translations and has no normal epsilon argument; it expects 4-D image batches. - Randomized models: wrap the model with EOT before a compatible gradient attack; EOT averages repeated model outputs and may be expensive.
Use references/troubleshooting.md for
unsupported criteria, missing distances, invalid epsilons, bounds, channel
axes, and optional-backend failures. For authoring, read
references/attack-authoring.md.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).