Skip to main content

PAC Bayes Bounds Framework - A Toolkit for PAC-Bayes Analysis

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.

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

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)

  • maxtretiakov (Maksym Tretiakov)

Citing

If you use this code, please cite as:

@software{mardan2025pacbbframework,
  author       = {Yauheni Mardan and Maksym Tretiakov and Alexander Immer and Vincent Fortuin},               
  title        = {pacbb: PAC-Bayes Bounds Evaluation Framework},
  month        = {march},
  year         = {2025},
  doi          = {10.5281/zenodo.15082669},
  url          = {https://doi.org/10.5281/zenodo.15082670}
  howpublished = {https://github.com/fortuinlab/pacbb}
}

Metadata

Release files for pacbb 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 pacbb 0.1.2
File Size Uploaded Provenance Actions
pacbb-0.1.2.tar.gz 12.3 kB With provenance Details for pacbb-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pacbb 0.1.2
File Interpreter ABI Platform Actions
pacbb-0.1.2-py3-none-any.whl Python 3 none any Details for pacbb-0.1.2-py3-none-any.whl

Total release size: 25.0 kB

Release files / pacbb-0.1.2.tar.gz

Download URL pacbb-0.1.2.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
44c3bb18eb7e48b10d288072b3aeabd50ffcbde0bacb4a4f1a7c876c747d6e56
BLAKE2b-256 checksum
How to use checksums
5a786885fa3b124df921b52f9f1525c797d16e607f29a89d244de6d94ff420a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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 Mar 25, 2025.

Transparency log

Release files / pacbb-0.1.2-py3-none-any.whl

Download URL pacbb-0.1.2-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f87624d8ebea4673319b6f012def4c4b087e71e09815a4d2e001f16a5ae64bc
BLAKE2b-256 checksum
How to use checksums
bf5d584eb9149accdc0cd7b8b54cad3f6bc0ff7b499050d1aa9d20ac5a1a7004
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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 Mar 25, 2025.

Transparency log

Security for pacbb 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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pacbb-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 Mar 25, 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.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files Full provenance

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