You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The first term is called the positive phase and we assume that we have a model for the function $f$ from which we can sample values. Below we will develop an explicit model for this.
174
+
The first term is called the positive phase and we assume that we have a model for the function $f$ from which we can sample values.
174
175
The second term is called the negative phase and is the one which leads to more difficulties.
is in general the most problematic term. In principle both $x$ and $h$ can span large degrees of freedom, if not even infinitely many ones, and computing the partition function itself is often not desirable or even feasible. The above derivative of the partition function can however be written in terms of an expectation value which is in turn evaluated using Monte Carlo sampling and the theory of Markov chains, popularly shortened to MCMC (or just MC$^2$).
186
187
187
-
!split
188
-
===== Explicit expression for the derivative =====
This quantity is evaluated using Monte Carlo sampling, with Gibbs
235
-
sampling as the standard sampling rule. Before we discuss the
236
-
explicit algorithms, we need to remind ourselves about Markov chains
237
-
and sampling rules like the Metropolis-Hastings algorithm and Gibbs
238
-
sampling.
212
+
sampling as the standard sampling rule.
213
+
214
+
215
+
!split
216
+
===== Kullback-Leibler divergence =====
217
+
218
+
The Kullback–Leibler (KL) divergence, labeled $D_{KL}$, measures how one probability distribution $p$ diverges from a second expected probability distribution $q$,
# Code example for a Quantum Boltzmann Machine (QBM) applied to a binary classification problem using PennyLane. This example uses a simplified dataset (XOR problem) and trains a parameterized quantum circuit to model the joint distribution of features and labels.
666
+
This code defines a target distribution (e.g., classical binary data) using a Variational Quantum Boltzmann machines (VQBM).
667
+
At each epoch it trains the model and samples the model and final computes the histogram probabilities.
666
668
669
+
!bc pycod
667
670
import pennylane as qml
668
671
from pennylane import numpy as np
672
+
import matplotlib.pyplot as plt
673
+
from matplotlib.animation import FuncAnimation
674
+
from collections import Counter
675
+
676
+
# Config
677
+
num_visible = 2
678
+
num_hidden = 2
679
+
num_qubits = num_visible + num_hidden
680
+
epochs = 50
681
+
shots = 1000
682
+
683
+
dev = qml.device("default.qubit", wires=num_qubits, shots=shots)
1. **Dataset**: Uses XOR problem with binary features and labels encoded in 3 qubits (2 features, 1 label).
746
-
747
-
2. **Quantum Circuit**:
748
-
- Uses rotation gates (RX, RY) and entangling gates (CNOT)
749
-
- Parameters are optimized to match the target distribution
750
-
- Outputs probabilities for all possible 8 states
751
-
752
-
3. **Training**:
753
-
- Minimizes KL divergence between model and target probabilities
754
-
- Uses Adam optimizer for better convergence
755
-
756
-
4. **Prediction**:
757
-
- Calculates conditional probabilities p(label|features) by marginalizing the joint distribution
758
-
- Normalizes probabilities for classification
759
-
760
-
**Note:** This is a simplified example. For real-world applications, you would need to:
761
-
1. Handle continuous features (e.g., using amplitude encoding)
762
-
2. Use more sophisticated ansatz architectures
763
-
3. Implement proper batching for larger datasets
764
-
4. Add regularization to prevent overfitting
765
-
766
-
The output should show decreasing cost during training and high probabilities for correct labels in predictions. Actual results may vary due to random initialization and optimization challenges.
0 commit comments