evasion-and-preprocessing
Use ART evasion attacks, preprocessing defences, and adversarial training recipes for image/tabular robustness workflows.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- evasion-and-preprocessing
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Use ART evasion attacks, preprocessing defences, and adversarial training recipes for image/tabular robustness workflows.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/attack-api-reference.md10.7 KB
- 参考文档references/preprocessing-and-training.md9.6 KB
- 参考文档references/troubleshooting.md7.0 KB
- 脚本scripts/smoke_evasion_pytorch.py4.3 KB
- 脚本scripts/smoke_preprocessor_numpy.py2.9 KB
03 SKILL.md 正文
Evasion and preprocessing
Use this sub-skill when the task is to generate evasion adversarial examples, select a white-box/black-box/physical image attack, add preprocessing defences, or plan adversarial training with ART estimators.
Route here
- Craft FGSM/FGM, PGD/BIM/MIM/AutoPGD/AutoAttack, Carlini, DeepFool, ElasticNet, JSMA, universal perturbation, virtual adversarial, HopSkipJump, Boundary, ZOO, SimBA, Square, Pixel/Threshold, SignOPT, DecisionTree, spatial, feature-adversary, or image-patch attacks.
- Add image/tabular preprocessing defences such as standardisation, spatial smoothing, feature squeezing, JPEG compression, Gaussian augmentation, label smoothing, Mixup, CutMix, Cutout, thermometer encoding, total variation minimization, or PixelDefend.
- Plan adversarial training with
AdversarialTrainer,AdversarialTrainerMadryPGD, or TRADES-style trainers.
Route away
- Model wrapping,
clip_values,input_shape, backend device setup, and estimator construction details belong to../estimators-and-models/or../setup-and-backends/. - Poisoning, backdoors, membership/attribute inference, model inversion, or model extraction belong to
../poisoning-inference-extraction/. - Robustness metrics, certification, tree verification, security curves, and gradient checks after attack generation belong to
../evaluation-and-certification/. - Speech, object-detection-heavy, malware, and audio-heavy evasion workflows are outside this selected runtime scope unless a future refresh adds their required backends. Recognize their ART class names, but do not promise runnable coverage here.
Operating sequence
- Confirm the estimator capability: loss gradients for PGD/FGM/BIM/MIM/AutoPGD, class gradients for Carlini/DeepFool/JSMA-style attacks, prediction-only classifiers for hard-label black-box attacks, or neural-network/image-specific support for patch/spatial attacks.
- Match all perturbation budgets to the estimator input scale and
clip_values; for normalized[0, 1]images use budgets such as8/255, not8. - Check shape conventions before running an attack: PyTorch image estimators usually use
channels_first=TrueandNCHW; many NumPy image preprocessors default tochannels_first=FalseandNHWC. - For targeted attacks, pass target labels as
ytogenerate; use one-hot labels unless the wrapped estimator workflow explicitly uses class-index labels. - Add preprocessing defences either directly as callable preprocessors or through estimator
preprocessing_defences; do not treat preprocessing alone as proof of robustness. - For adversarial training, start from a bounded PGD/FGM attack, verify labels and clipping, then choose generic, Madry PGD, or TRADES training according to the estimator backend.
References
- Attack family/API chooser: references/attack-api-reference.md
- Preprocessing and adversarial training recipes: references/preprocessing-and-training.md
- Evasion/preprocessing troubleshooting: references/troubleshooting.md
Bundled checks
- Tiny CPU PyTorch PGD/FGM smoke: scripts/smoke_evasion_pytorch.py
- Tiny NumPy standardisation/spatial smoothing smoke: scripts/smoke_preprocessor_numpy.py
Run bundled scripts with --help first; they use synthetic data and do not download datasets.
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).