RBMs
Overview
rbms is a GPU-accelerated package designed to train and analyze Restricted Boltzmann Machines (RBMs). It is intended for students and researchers who need an efficient tool for working with RBMs.
Features:
- GPU Acceleration through PyTorch.
- Multiple model types: Bernoulli, Ising, Potts and Gaussian units (
BBRBM,IIRBM,PBRBM,BGRBM,IGRBM) and a fully connected Potts model (PBM). - Training with PCD, CD, RDM or a Jarzynski sampler, and parallel tempering for sampling.
- The log partition function (log Z) and the log-likelihoods, estimated during training or computed afterwards on the saved models.
- Reproducible runs: a run file records its config and dataset, and a run restored mid-way continues as an uninterrupted one would.
- Extensible Design: models, samplers, gradient transforms and log Z estimators are registered by name, and a separate package can add its own through the
rbms.pluginsentry points.
Installation
PyPI
rbms can be installed from PyPI:
pip install rbms
Each release on PyPI is tagged in this repo (v0.7.0, ...); the changes of each release are in its
release notes. To update the installed
package run
pip install rbms --upgrade
Github
If you want the latest development version (the develop branch) or wish to contribute, you can
install the package directly from this repository:
git clone git@github.com:DsysDML/rbms.git
cd rbms && pip install -e .
If you want to update the package run
git pull
from inside the cloned repo.
Dependencies
The dependencies are included in the pyproject.toml file and should be compiled in the wheel distribution. If you have a GPU, make sure to install PyTorch with GPU support.
Usage
Main Classes and Functions:
EBM: An abstract class that provides the basic structure and methods for Energy-Based Models (EBMs).RBM: An abstract class that provides the basic structure and methods for RBMs.BBRBM: A concrete implementation of the Bernoulli-Bernoulli RBM.PBRBM: A concrete implementation of the Potts-Bernoulli RBM.rbms.sampler: Submodule for sampling methods.rbms.training: Submodule for training algorithms.
Basic Example
Train a RBM on MNIST-01 with PCD-100 for 10 000 steps, using 200 hidden nodes and 2000 permanent chains:
rbms train -d ./data/MNIST.h5 --subset_labels 0 1 \
--num_hiddens 200 --gibbs_steps 100 --num_chains 2000 \
--num_updates 10000 --filename ./RBM_MNIST01.h5
Add --log_z trajectory to estimate log Z along the training: each saved update then holds
log Z and the train and test log-likelihoods.
Continue the same run up to 20 000 updates. The run file records its config and its data, so the other options can be left out:
rbms train --restore --filename ./RBM_MNIST01.h5 --num_updates 20000
Compute log Z and the log-likelihoods of the saved updates afterwards, by AIS
(--log_z exact enumerates small models exactly):
rbms evaluate ./RBM_MNIST01.h5
Run files written by rbms 0.6 and 0.7 still load and resume. rbms evaluate needs the newer
format: rbms upgrade writes a copy of an old file in it, leaving the original untouched
(-d records the run's dataset in the copy):
rbms upgrade ./old_run.h5 ./old_run_upgraded.h5 -d ./data/MNIST.h5
Documentation
The documentation is available at https://dsysdml.github.io/rbms/
Contributing
We welcome contributions to the development of TorchRBM. Here's how you can contribute:
- Fork the Repository: Fork the main repository and make your changes.
- Propose a Merge Request: Once your changes are complete, propose a merge request.
- Testing: Ensure your code is tested using the pytest framework. Include your tests in the tests folder.
- Code Style: Follow the pre-commit configuration for code style.
- Documentation: Document your code using the Google docstring style and provide type hints .
- Dependencies: Avoid adding extra dependencies unless absolutely necessary.
Support
If you encounter any issues, please open an issue on the main repository.
License
rbms is released under the MIT License.
Metadata
Release files for rbms 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rbms-0.8.0-py3-none-any.whl | Python 3 | none | any | Details for rbms-0.8.0-py3-none-any.whl |
Release files / rbms-0.8.0-py3-none-any.whl
| Download URL | rbms-0.8.0-py3-none-any.whl |
|---|---|
| Size | 193.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e42dfed66cb6ce44b82684aa8da5d00b7678446863b9296617804c49ea3401c8
|
|
BLAKE2b-256 checksum How to use checksums |
8b70078d46a93b76e1bd7d9ca7b2a0ec401cf9c19b24cf8d1be750efa9ad183e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for rbms 0.8.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.