CTRAIN


NameCTRAIN JSON
Version 0.1.2 PyPI version JSON
download
home_pageNone
SummaryCTRAIN is an unified, modular and comprehensive package for the training and evaluation of certified training techniques.
upload_time2025-02-07 16:36:33
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2025 Konstantin Kaulen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords certified training robustness machine learning verification
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

- Interval Bound Propagation (IBP) ([Gowal et al., 2018](https://arxiv.org/abs/1810.12715) with the Improvements of [Shi et al., 2021](https://arxiv.org/abs/2102.06700))
- CROWN-IBP ([Zhang et al., 2020](https://arxiv.org/abs/1906.06316))
- SABR ([Müller et al., 2023](https://arxiv.org/pdf/2210.04871))
- TAPS ([Mao et al., 2023](https://proceedings.neurips.cc/paper_files/paper/2023/file/e8b0c97b34fdaf58b2f48f8cca85e76a-Paper-Conference.pdf))
- STAPS (combination of SABR and TAPS, [Mao et al., 2023](https://proceedings.neurips.cc/paper_files/paper/2023/file/e8b0c97b34fdaf58b2f48f8cca85e76a-Paper-Conference.pdf))
- MTL-IBP ([De Palma et al., 2023](https://arxiv.org/pdf/2305.13991))

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

- Adversarial Robustness
  - PGD ([Madry et al., 2018](https://arxiv.org/abs/1706.06083))

- Certified Robustness (Incomplete Verification using `auto_LiRPA`, [Xu et al., 2020](https://proceedings.neurips.cc/paper/2020/file/0cbc5671ae26f67871cb914d81ef8fc1-Paper.pdf))
  - IBP ([Gowal et al., 2018](https://arxiv.org/abs/1810.12715))
  - CROWN-IBP ([Zhang et al., 2020](https://arxiv.org/abs/1906.06316))
  - CROWN ([Zhang et al., 2018](https://arxiv.org/abs/1811.00866))

- Certified Robustness (Complete Verification)
  - α,β-CROWN ([Xu et al., 2020](https://arxiv.org/pdf/2011.13824), [Wang et al., 2021](https://arxiv.org/abs/2103.06624))

## 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](https://www.jmlr.org/papers/volume23/21-0888/21-0888.pdf))
- 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`:
```sh
pip install CTRAIN
```
Or, to setup the package for development purposes, run:
```sh
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:
```python
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](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.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "CTRAIN",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "certified training, robustness, machine learning, verification",
    "author": null,
    "author_email": "Konstantin Kaulen <kaulen@aim.rwth-aachen.de>",
    "download_url": "https://files.pythonhosted.org/packages/e1/8c/0158b73165ceac771be8104b2b457abdcf91d1028692afb40e5e95d164be/ctrain-0.1.2.tar.gz",
    "platform": null,
    "description": "# CTRAIN\n\nCTRAIN is a unified, modular and comprehensive package for training and evaluating certified training techniques for neural networks.\n\n## Overview\n\nCTRAIN integrates multiple state-of-the-art certified training approaches, which are:\n\n- Interval Bound Propagation (IBP) ([Gowal et al., 2018](https://arxiv.org/abs/1810.12715) with the Improvements of [Shi et al., 2021](https://arxiv.org/abs/2102.06700))\n- CROWN-IBP ([Zhang et al., 2020](https://arxiv.org/abs/1906.06316))\n- SABR ([M\u00fcller et al., 2023](https://arxiv.org/pdf/2210.04871))\n- TAPS ([Mao et al., 2023](https://proceedings.neurips.cc/paper_files/paper/2023/file/e8b0c97b34fdaf58b2f48f8cca85e76a-Paper-Conference.pdf))\n- STAPS (combination of SABR and TAPS, [Mao et al., 2023](https://proceedings.neurips.cc/paper_files/paper/2023/file/e8b0c97b34fdaf58b2f48f8cca85e76a-Paper-Conference.pdf))\n- MTL-IBP ([De Palma et al., 2023](https://arxiv.org/pdf/2305.13991))\n\nFurthermore, CTRAIN enables easy evaluation of the adversarial and certified robustness of a given neural network, using the following methods:\n\n- Adversarial Robustness\n  - PGD ([Madry et al., 2018](https://arxiv.org/abs/1706.06083))\n\n- Certified Robustness (Incomplete Verification using `auto_LiRPA`, [Xu et al., 2020](https://proceedings.neurips.cc/paper/2020/file/0cbc5671ae26f67871cb914d81ef8fc1-Paper.pdf))\n  - IBP ([Gowal et al., 2018](https://arxiv.org/abs/1810.12715))\n  - CROWN-IBP ([Zhang et al., 2020](https://arxiv.org/abs/1906.06316))\n  - CROWN ([Zhang et al., 2018](https://arxiv.org/abs/1811.00866))\n\n- Certified Robustness (Complete Verification)\n  - \u03b1,\u03b2-CROWN ([Xu et al., 2020](https://arxiv.org/pdf/2011.13824), [Wang et al., 2021](https://arxiv.org/abs/2103.06624))\n\n## Key Features\nCTRAIN has the goal of providing an unified, comprehensive, accessible and flexible framework for certified training. Key features include:\n- Standardised, modular and hihly-configurable implementations of popular and performant certified training methods based on the popular `auto_LiRPA` library\n- Unified and accessible interface through model wrappers\n- Based on PyTorch for easy integration into common machine learning pipelines\n- Seamless integration of sophisticated hyperparameter optimisation using SMAC3 ([Lindauer et al., 2022](https://www.jmlr.org/papers/volume23/21-0888/21-0888.pdf))\n- Comprehensive evaluation tools for adversarial and certified robustness\n  - Support for both incomplete and complete verification methods, including the state-of-the-art complete verification system \u03b1,\u03b2-CROWN\n- Detailed documentation with API reference, setup guide, and usage examples\n- Open-source with a permissive MIT license\n- Active development and maintenance by the Chair for Artificial Intelligence Methodology at RWTH Aachen University\n\n## Installation and Quick Start\nFirst, install CTRAIN using `pip`:\n```sh\npip install CTRAIN\n```\nOr, to setup the package for development purposes, run:\n```sh\ngit submodule init\ngit submodule update\npip install --no-deps git+https://github.com/KaidiXu/onnx2pytorch@8447c42c3192dad383e5598edc74dddac5706ee2\npip install --no-deps git+https://github.com/Verified-Intelligence/auto_LiRPA.git@cf0169ce6bfb4fddd82cfff5c259c162a23ad03c\"\npip install -e \".[dev]\"\n```\nThen, 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:\n```python\nfrom CTRAIN.model_definitions import CNN7_Shi\nfrom CTRAIN.data_loaders import load_cifar10\nfrom CTRAIN.model_wrappers import ShiIBPModelWrapper\n\ntrain_loader, test_loader = load_cifar10(val_split=False)\nin_shape = [3, 32, 32]\n\nmodel = CNN7_Shi(in_shape=in_shape)\nwrapped_model = ShiIBPModelWrapper(model=model, input_shape=in_shape, eps=2/255, num_epochs=160)\n\nwrapped_model.train_model(train_loader)\nstd_acc, cert_acc, adv_acc = wrapped_model.evaluate(test_loader)\n```\n## Project Structure\n\n```\nCTRAIN/\n\u251c\u2500\u2500 attacks/            # Implementation of attacks\n\u251c\u2500\u2500 bound/             # Bound computation approaches\n\u251c\u2500\u2500 complete_verification/ # Complete verification\n\u251c\u2500\u2500 data_loaders/      # Dataset loading utilities  \n\u251c\u2500\u2500 eval/              # (Incomplete) Evaluation functionality\n\u251c\u2500\u2500 model_definitions/ # Neural network architectures\n\u251c\u2500\u2500 model_wrappers/    # Model wrappers for different approaches\n\u251c\u2500\u2500 train/            # Robust/Certified Training implementations\n\u251c\u2500\u2500 util/             # Utility functions\n\u2514\u2500\u2500 verification_systems/ # External verification tools\n```\n\n## Documentation\n\nDocumentation is available in the docs directory, including:\n\n- API Reference\n- Setup Guide\n- Usage Examples\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n\n## Maintainers\nThis 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.\nKonstantin Kaulen is the current core-maintainer of the project.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit issues and pull requests.\n\n## Acknowledgements\n\nThis project incorporates the \u03b1,\u03b2-CROWN verifier which is developed by a multi-institutional team led by Prof. Huan Zhang. The \u03b1,\u03b2-CROWN components are licensed under the BSD 3-Clause license.\nFurthermore, CTRAIN depends heavily on the `auto_LiRPA` library, which is developed by the same team and also licensed under the BSD 3-Clause License.\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2025 Konstantin Kaulen\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.",
    "summary": "CTRAIN is an unified, modular and comprehensive package for the training and evaluation of certified training techniques.",
    "version": "0.1.2",
    "project_urls": null,
    "split_keywords": [
        "certified training",
        " robustness",
        " machine learning",
        " verification"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e18c0158b73165ceac771be8104b2b457abdcf91d1028692afb40e5e95d164be",
                "md5": "e46061d835b60d80dcb51cb0d8664b02",
                "sha256": "2f0beea2c4c22d5d98c9b5271301267cc7e6d0bf51104360c0110ec204577443"
            },
            "downloads": -1,
            "filename": "ctrain-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "e46061d835b60d80dcb51cb0d8664b02",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 297138,
            "upload_time": "2025-02-07T16:36:33",
            "upload_time_iso_8601": "2025-02-07T16:36:33.696971Z",
            "url": "https://files.pythonhosted.org/packages/e1/8c/0158b73165ceac771be8104b2b457abdcf91d1028692afb40e5e95d164be/ctrain-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-07 16:36:33",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "ctrain"
}
        
Elapsed time: 0.38261s