This directory contains example scripts to help you get started with CertifiedAttack.
An interactive script that guides you through running different attack scenarios:
python examples/quick_start.py --demoThis will present you with a menu of pre-configured attack examples to choose from.
A minimal example showing how to run attacks programmatically:
# Basic usage
python examples/simple_attack.py
# Specify model and dataset
python examples/simple_attack.py --model vgg --dataset cifar100
# Different attack
python examples/simple_attack.py --attack PointWiseCompare multiple attacks on the same model:
python examples/compare_attacks.py --model resnet --dataset cifar10Evaluate attacks against different defense mechanisms:
python examples/evaluate_defenses.py --defense blacklightExample of creating and using custom configurations:
python examples/custom_config_example.pyFor interactive exploration, check out our Jupyter notebooks:
notebooks/01_getting_started.ipynb- Introduction to CertifiedAttacknotebooks/02_attack_visualization.ipynb- Visualizing attack resultsnotebooks/03_defense_comparison.ipynb- Comparing defense mechanismsnotebooks/04_custom_attacks.ipynb- Implementing custom attacks
-
Ensure you have trained models in the
experiments/directory:python train.py --config configs/cifar10/resnet.yaml
-
Install all dependencies:
pip install -r requirements.txt
-
Run from the project root directory:
cd /path/to/CertifiedAttack python examples/simple_attack.py
- No checkpoint found: Train a model first using the training scripts
- CUDA out of memory: Reduce batch size in the examples
- Import errors: Make sure you're running from the project root directory
To create custom examples:
- Copy one of the existing examples as a template
- Modify the configuration parameters
- Add your custom logic
- Save in the examples directory
Example structure:
import sys
sys.path.append('..') # Add parent directory to path
from pytorch_image_classification import create_model, create_dataloader
from attacks import get_attack
# Your custom code here- Check the Usage Guide for detailed documentation
- Review the configuration files for more options
- Open an issue on GitHub for specific questions