PAC Bayes Bound toolset
Project description
About
The pacbb repository provides a collection of handy tools for PAC Bayes bounds evaluation. It is designed to simplify the work of PAC Bayes enthusiasts by offering various utilities and resources for easier implementation and experimentation.
We have prepared an arXiv paper that outlines the structure of pacbb, demonstrates its usage, structure, and presents a series of experiments conducted using the toolkit.
Links
- Documentation: https://yauhenii.github.io/pacbb/core.html
- PyPI: https://pypi.org/project/pacbb/
- Source Code: https://github.com/yauhenii/pacbb
- Issues: https://github.com/yauhenii/pacbb/issues
- ArXiv: TODO
Installation
To install the pacbb package, use the following command:
pip install pacbb
Example
For a complete example, please refer to the full script in scripts/generic_train.py.
Here is a part of this script showing how to convert a standard model to a Probabilistic Neural Network (ProbNN), which can be used for PAC Bayes boundaries calculation:
from core.model import dnn_to_probnn
from core.distribution import GaussianVariable
from core.distribution.utils import from_random, from_zeros
# Initialize prior
prior_reference = from_zeros(model=model,
rho=torch.log(torch.exp(torch.Tensor([sigma])) - 1),
distribution=GaussianVariable,
requires_grad=False)
prior = from_random(model=model,
rho=torch.log(torch.exp(torch.Tensor([sigma])) - 1),
distribution=GaussianVariable,
requires_grad=True)
# Convert the model to ProbNN
dnn_to_probnn(model, prior, prior_reference)
Distributions creation and model conversion are explained in details in the arXive paper.
Experiments
To run the experiments from the arXiv paper, follow these steps:
- Clone the repository:
git clone https://github.com/Yauhenii/pacbb.git
- Set up the environment:
conda create --prefix=./conda_env python=3.11 pip install -r requirements.txt
- Create your desired experiment configuration:
./config
- Run the configuration using the Python script directly:
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
python scripts/ivon_generic_train.py --config ./config/ivon_generic_configs/best_ivon.yaml
Alternatively, run multiple configuration files using a bash script wrapper:
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
bash jobs/runnig_ivon_configs_in_the_folder.sh ./config/ivon_generic_configs/best_ivon.yaml
Contribution
Contributions to pacbb are welcome! To contribute:
- Fork the repository.
- Create a new branch from
main. - Make your changes.
- Submit a pull request to the
mainbranch.
Please use the following naming conventions for your branches:
feature/short-descriptionfor new feature proposals.bugfix/short-descriptionfor bug fixes.experiments/short-descriptionfor changes related to thescriptsmodule.
Acknowledgments
Special thanks to Vincent Fortuin and Alex Immer for their supervision, support, and contributions to this project. Their guidance has been invaluable throughout the development of pacbb.
Authors
-
Yauhenii (Yauheni Mardan)
-
Misipuk (Maksym Tretiakov)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pacbb-0.1.tar.gz.
File metadata
- Download URL: pacbb-0.1.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a957a35831969e212015a50ac07729b59fbe9ee13615fdb82399f549626c1fa9
|
|
| MD5 |
6182b1ddefa06f86b31fd1651b2be0a8
|
|
| BLAKE2b-256 |
2f4202d64d306b9fe3e5a32cdb1821ca9f57159c0c7ff530d56227a97b628ae9
|
Provenance
The following attestation bundles were made for pacbb-0.1.tar.gz:
Publisher:
publish.yml on Yauhenii/pacbb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pacbb-0.1.tar.gz -
Subject digest:
a957a35831969e212015a50ac07729b59fbe9ee13615fdb82399f549626c1fa9 - Sigstore transparency entry: 163674383
- Sigstore integration time:
-
Permalink:
Yauhenii/pacbb@6a9020ac083cd3acd89bd9244896fad177ecb613 -
Branch / Tag:
refs/tags/v0.1 - Owner: https://github.com/Yauhenii
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6a9020ac083cd3acd89bd9244896fad177ecb613 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pacbb-0.1-py3-none-any.whl.
File metadata
- Download URL: pacbb-0.1-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c802b261abdf76001dcce208321269ffca3bc17e9dee122dc1a83c968bb6da1
|
|
| MD5 |
eb06f5c651f0ed670170e5abd492a8f3
|
|
| BLAKE2b-256 |
449740d118ebc8bcdd0c118ac3012a2dd565694c6fb5b9f894e9ffb5a62af63c
|
Provenance
The following attestation bundles were made for pacbb-0.1-py3-none-any.whl:
Publisher:
publish.yml on Yauhenii/pacbb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pacbb-0.1-py3-none-any.whl -
Subject digest:
8c802b261abdf76001dcce208321269ffca3bc17e9dee122dc1a83c968bb6da1 - Sigstore transparency entry: 163674384
- Sigstore integration time:
-
Permalink:
Yauhenii/pacbb@6a9020ac083cd3acd89bd9244896fad177ecb613 -
Branch / Tag:
refs/tags/v0.1 - Owner: https://github.com/Yauhenii
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6a9020ac083cd3acd89bd9244896fad177ecb613 -
Trigger Event:
release
-
Statement type: