Skip to main content

PAC Bayes Bound toolset

Project description

Docs PyPI GitHub release License Archive

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

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:

  1. Clone the repository:
git clone https://github.com/Yauhenii/pacbb.git
  1. Set up the environment:
conda create --prefix=./conda_env python=3.11 pip install -r requirements.txt
  1. Create your desired experiment configuration:
./config
  1. 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:

  1. Fork the repository.
  2. Create a new branch from main.
  3. Make your changes.
  4. Submit a pull request to the main branch.

Please use the following naming conventions for your branches:

  • feature/short-description for new feature proposals.
  • bugfix/short-description for bug fixes.
  • experiments/short-description for changes related to the scripts module.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pacbb-0.1.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pacbb-0.1-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

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

Hashes for pacbb-0.1.tar.gz
Algorithm Hash digest
SHA256 a957a35831969e212015a50ac07729b59fbe9ee13615fdb82399f549626c1fa9
MD5 6182b1ddefa06f86b31fd1651b2be0a8
BLAKE2b-256 2f4202d64d306b9fe3e5a32cdb1821ca9f57159c0c7ff530d56227a97b628ae9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pacbb-0.1.tar.gz:

Publisher: publish.yml on Yauhenii/pacbb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for pacbb-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8c802b261abdf76001dcce208321269ffca3bc17e9dee122dc1a83c968bb6da1
MD5 eb06f5c651f0ed670170e5abd492a8f3
BLAKE2b-256 449740d118ebc8bcdd0c118ac3012a2dd565694c6fb5b9f894e9ffb5a62af63c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pacbb-0.1-py3-none-any.whl:

Publisher: publish.yml on Yauhenii/pacbb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page