15. Restricted Boltzmann Machine — Learning Distributions through Energy
Probabilistic Model 1/1. An RBM is a generative model that connects observed and latent variables in a bipartite graph and learns the data distribution through an energy function. The key is adjusting parameters to assign low energy to good data and high energy to poor reconstructions. Background: probability spaces, expectations and moments, and differentiation and optimization.
Goal of a generative model
A supervised model usually learns a function that predicts the correct answer from an input . A generative model instead tries to learn where data is abundant: the probability distribution .
Knowing the distribution makes two things possible:
- Score how plausible observed data is.
- Draw new samples from the distribution.
A Restricted Boltzmann Machine (RBM) solves this objective as an energy-based model. A state with lower energy has higher probability, and a state with higher energy has lower probability.
What is restricted in a Boltzmann Machine?
A general Boltzmann Machine is a probabilistic graph in which several nodes are connected. Its nodes are divided into two types:
- visible unit — the data actually observed
- hidden unit — an unobserved variable that explains latent factors in the data
The problem is that if every node is connected to every other node, calculating conditional distributions becomes too complex. The restriction in an RBM is simple:
Remove visible-visible and hidden-hidden connections, leaving only visible-hidden connections.
Once the graph becomes bipartite, units within the same layer are conditionally independent. Given , every hidden unit can therefore be sampled in parallel; conversely, given , every visible unit can be sampled in parallel.
Structure and parameters
In a Bernoulli RBM, each unit has value 0 or 1.
| Symbol | Meaning | Dimension |
|---|---|---|
| visible vector | ||
| hidden vector | ||
| visible bias | ||
| hidden bias | ||
| visible-hidden weight matrix |
represents how easily visible unit turns on, and represents how easily hidden unit turns on. determines how much the energy decreases when and are on together.
Energy and probability
The energy of an RBM is defined as
Turning this energy into a probability gives the Boltzmann distribution:
is the partition function. It is difficult to calculate exactly because every possible combination of must be summed. This normalization constant is precisely what makes RBM training difficult.
The probability of observed data is obtained by marginalizing every hidden state:
In terms of free energy,
and the free energy of a Bernoulli RBM is
Here is the th row of .
Conditional distributions — where the RBM becomes tractable
Thanks to the RBM's bipartite structure, hidden units are conditionally independent of one another given :
Conversely, visible units are conditionally independent of one another given :
Here . These two expressions make RBMs practical. Although itself is difficult, and are calculated directly as a sigmoid for each unit.
Training objective — lower the free energy of data
An RBM is trained to increase the likelihood of the data. For one observation , the gradient of the negative log-likelihood has the structure
The first term is the positive phase. It lowers the free energy of real data . The second term is the negative phase. It raises the free energy of samples produced by the model itself in relative terms, preventing probability mass from being spread everywhere.
The problem is that the expectation over the model distribution is difficult to obtain exactly. It is therefore approximated through sampling.
Contrastive Divergence
Contrastive Divergence (CD) approximates the negative phase with a short Gibbs chain.
- Place data in the visible layer.
- Sample .
- Sample .
- If needed, repeat the process times to obtain .
- Update in the direction that reduces the difference .
CD-1 makes only one round trip. Surprisingly, in many early applications, even this short approximation produced useful features. This is also why RBMs were important for pretraining Hinton's deep belief networks.
Gibbs sampling in an RBM does not create candidates and accept or reject them as Metropolis-Hastings does. It samples directly and alternately from and . The RBM's restriction is precisely the structure that makes this direct sampling possible.
Similar to an autoencoder, but with a different objective
One RBM step superficially resembles an autoencoder:
The interpretation differs, however.
| Model | Intermediate representation | Objective |
|---|---|---|
| Autoencoder | deterministic code | Minimize reconstruction error |
| RBM | stochastic hidden state | Increase likelihood of the data distribution |
An RBM reconstruction is not a simple copy but a sample drawn from the model distribution. A well-trained RBM therefore forms low-energy regions where data lies rather than memorizing its inputs.
Where was it used?
RBMs are no longer the mainstream of modern generative models, but they played an important role in deep-learning history.
- Unsupervised feature learning — learn hidden representations without labels
- Deep Belief Network pretraining — initialize deep networks through layerwise RBM training
- Collaborative filtering — model binary user-item preference patterns
- Introductory example of an energy-based model — demonstrate the essentials of partition functions, free energy, and MCMC training in a small structure
VAE, GAN, and diffusion models now dominate generative modeling, but RBMs remain a good starting point for understanding the perspective of "modeling the distribution directly" and the basic grammar of energy-based learning.
What to remember from this page
- An RBM is an energy-based generative model with a visible-hidden bipartite graph.
- Thanks to the restricted structure, and factor into sigmoid conditional distributions.
- , and low-energy states have high probability.
- The free energy scores a visible configuration after marginalizing hidden states.
- Contrastive Divergence approximates the likelihood gradient using the free-energy difference between real data and a short Gibbs reconstruction sample.
Reference
- Engineer's Mathematics Notes, Restricted Boltzmann Machine.
Full series index: Math:: index