Skip to main content

A Python package for training and analyzing quantum Boltzmann machines

Project description

Quantum Boltzmann Machines

The qbm Python package is designed for training and analyzing quantum Boltzmann machines (QBMs) using either a simulation or a D-Wave quantum annealer. The QBM implemented here is based on the work in Quantum Boltzman Machine by Amin et al. [1]. This package originated as part of the thesis Quantum Boltzmann Machines: Applications in Quantitative Finance.

Table of Contents

Installation

The qbm package can be installed with

pip install qbm

Usage

Basic Configuration

The qbm package is mainly configured around the project directory, which can be set with the QBM_PROJECT_DIR environment variable. Once the environment variable is set one can use the qbm.utils.get_project_dir() function to get a path object to the directory.

BQRBM Model

The BQRBM, or bound-based quantum restricted Boltzmann machine, is a quantum Boltzmann machine that has intra-layer restrictions and is trained via maximization of the log-likelihood lower bound. The model currently only has the ability to train in the specific case where s_freeze = 1, i.e., when it reduces to a classical RBM trained with quantum assistance, because estimating the effective inverse temperature is nontrivial for the general case.

All of the arguments to the methods below are further explained in their respective docstrings.

Instantiation

A BQRBM model can be instantiated as (for example)

model = BQRBM(
    V_train,
    n_hidden,
    A_freeze,
    B_freeze,
    beta_initial=1.0,
    simulation_params={"beta": 1.0},
    seed=0,
)

One needs to choose whether or not they want to train a model using a simulation or an annealer, and this is done by passing either simulation_params or annealer_params. Whichever is passed decides how the model is trained.

Training

The model can be trained by running

model.train(
    n_epochs=100,
    learning_rate=1e-1,
    learning_rate_beta=1e-1,
    mini_batch_size=10,
    n_samples=10_000,
    callback=None,
)

Sampling

The model can generate samples by running

model.sample(
    n_samples,
    answer_mode="raw",
    use_gauge=True,
    binary=False,
)

Saving and Loading

The model can be saved with

model.save("/path/to/model.pkl")

and loaded again with

model = BQRBM.load("/path/to/model.pkl")

Example

An example notebook can be found here

References

[1] Mohammad H. Amin et al. “Quantum Boltzmann Machine”. In: Phys. Rev. X 8 (2 May 2018), p. 021050. doi: 10.1103/PhysRevX.8.021050. url: https://link.aps.org/doi/10.1103/PhysRevX.8.021050.

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

qbm-0.1.2.tar.gz (4.0 MB view details)

Uploaded Source

Built Distribution

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

qbm-0.1.2-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file qbm-0.1.2.tar.gz.

File metadata

  • Download URL: qbm-0.1.2.tar.gz
  • Upload date:
  • Size: 4.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for qbm-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f879e90c80bd1d366cda5dfa28507666cae9dc416bbfee3adc1232167d30ae70
MD5 28514d06c8ac230d50f2efa91300bfd8
BLAKE2b-256 caa3f4345b0995ce629ba4a55d7a45ad779b0729f0f541cb5cec1af5e0de30c4

See more details on using hashes here.

File details

Details for the file qbm-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: qbm-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for qbm-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a411c2d5f00ccb936787b49ef673bddbc12da28f52eeb1bcc89b175aace89193
MD5 6f0ee5e578e68524714bfb073400e9c2
BLAKE2b-256 c63f5d823e166673786f9ef9e70d0f6e72e6ccb03280ef29b5600e8d431e8509

See more details on using hashes here.

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