Skip to main content

CTRAIN

CTRAIN is a unified, modular and comprehensive package for training and evaluating certified training techniques for neural networks.

Overview

CTRAIN integrates multiple state-of-the-art certified training approaches, which are:

Furthermore, CTRAIN enables easy evaluation of the adversarial and certified robustness of a given neural network, using the following methods:

Key Features

CTRAIN has the goal of providing an unified, comprehensive, accessible and flexible framework for certified training. Key features include:

  • Standardised, modular and hihly-configurable implementations of popular and performant certified training methods based on the popular auto_LiRPA library
  • Unified and accessible interface through model wrappers
  • Based on PyTorch for easy integration into common machine learning pipelines
  • Seamless integration of sophisticated hyperparameter optimisation using SMAC3 (Lindauer et al., 2022)
  • Comprehensive evaluation tools for adversarial and certified robustness
    • Support for both incomplete and complete verification methods, including the state-of-the-art complete verification system α,β-CROWN
  • Detailed documentation with API reference, setup guide, and usage examples
  • Open-source with a permissive MIT license
  • Active development and maintenance by the Chair for Artificial Intelligence Methodology at RWTH Aachen University

Installation and Quick Start

First, install CTRAIN using pip:

pip install CTRAIN

Or, to setup the package for development purposes, run:

git submodule init
git submodule update
pip install --no-deps git+https://github.com/KaidiXu/onnx2pytorch@8447c42c3192dad383e5598edc74dddac5706ee2
pip install --no-deps git+https://github.com/Verified-Intelligence/auto_LiRPA.git@cf0169ce6bfb4fddd82cfff5c259c162a23ad03c"
pip install -e ".[dev]"

Then, you can train and evaluate the standard CNN7 architecture proposed by Shi et al. on the CIFAR-10 dataset using the IBP certified training technique in 12 lines of code:

from CTRAIN.model_definitions import CNN7_Shi
from CTRAIN.data_loaders import load_cifar10
from CTRAIN.model_wrappers import ShiIBPModelWrapper

train_loader, test_loader = load_cifar10(val_split=False)
in_shape = [3, 32, 32]

model = CNN7_Shi(in_shape=in_shape)
wrapped_model = ShiIBPModelWrapper(model=model, input_shape=in_shape, eps=2/255, num_epochs=160)

wrapped_model.train_model(train_loader)
std_acc, cert_acc, adv_acc = wrapped_model.evaluate(test_loader)

Project Structure

CTRAIN/
├── attacks/            # Implementation of attacks
├── bound/             # Bound computation approaches
├── complete_verification/ # Complete verification
├── data_loaders/      # Dataset loading utilities  
├── eval/              # (Incomplete) Evaluation functionality
├── model_definitions/ # Neural network architectures
├── model_wrappers/    # Model wrappers for different approaches
├── train/            # Robust/Certified Training implementations
├── util/             # Utility functions
└── verification_systems/ # External verification tools

Documentation

Documentation is available in the docs directory, including:

  • API Reference
  • Setup Guide
  • Usage Examples

License

This project is licensed under the MIT License.

Maintainers

This project was developed at the Chair for Artificial Intelligence Methodology at RWTH Aachen University by Konstantin Kaulen under the supervision of Prof. Holger H. Hoos. Konstantin Kaulen is the current core-maintainer of the project.

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

Acknowledgements

This project incorporates the α,β-CROWN verifier which is developed by a multi-institutional team led by Prof. Huan Zhang. The α,β-CROWN components are licensed under the BSD 3-Clause license. Furthermore, CTRAIN depends heavily on the auto_LiRPA library, which is developed by the same team and also licensed under the BSD 3-Clause License.

Metadata

Release files for CTRAIN 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for CTRAIN 0.1.2
File Size Uploaded Provenance Actions
ctrain-0.1.2.tar.gz 297.1 kB With provenance Details for ctrain-0.1.2.tar.gz

Release files / ctrain-0.1.2.tar.gz

Download URL ctrain-0.1.2.tar.gz
Size 297.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2f0beea2c4c22d5d98c9b5271301267cc7e6d0bf51104360c0110ec204577443
BLAKE2b-256 checksum
How to use checksums
e18c0158b73165ceac771be8104b2b457abdcf91d1028692afb40e5e95d164be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 7, 2025.

Transparency log

Security for CTRAIN 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

1 file in this release has been uploaded with provenance metadata.

Attestation for ctrain-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 7, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page