Boltzmann machines: energies, Gibbs sampling and stacked layers
The energy models that started deep learning: an RBM samples one layer at a time, a deep belief network stacks RBMs, a deep Boltzmann machine needs mean-field updates. Why their training numbers mislead.
What runs in CodeSplash
- DNN040Restricted Boltzmann machine (RBM) Explained here
- DNN041Deep belief network (DBN) Explained here
- DNN042Deep Boltzmann machine (DBM) Explained here
You will be able to
- Write an energy model's probability and say why its normalizer is hard
- Run one block Gibbs step in an RBM and explain contrastive divergence
- Contrast a deep belief network's greedy stacking with a deep Boltzmann machine's mean-field inference
- Say why low reconstruction error after CD training says little about samples
Probability from an energy
ReadAn energy-based modelEnergy-based modelA model that scores configurations with an energy; probability is proportional to exp(−energy), divided by a usually intractable total. gives every configuration an energy and turns energies into probabilities:
Low energy means likely. The catch is , the partition functionPartition functionThe sum or integral of exp(−energy) over every configuration; it turns energies into probabilities and is rarely computable.: a sum over every possible configuration, which for 100 binary units already has terms. Most of what follows is about working around it.
The restricted Boltzmann machine
ReadA restricted Boltzmann machineRestricted Boltzmann machineAn energy model with a visible and a hidden layer and no links within a layer, so each layer is easy to sample given the other. has visible units and hidden units , with links only between the two layers:
No links within a layer means that, given , the hidden units are independent coins with , and the same the other way round. So you can sample a whole layer at once.
In the reference's example, one visible pattern turns on the two hidden units with probabilities 0.525 and 0.574.
Reference · DNN040 · Explained hereRestricted Boltzmann machine (RBM)An RBM is an undirected energy-based model with visible and hidden units but no within-layer edges. Conditional factorization permits efficient alternating Gibbs sampling, historically useful for feature learning and…Gibbs sampling, a layer at a time
ExploreAlternate: sample given , then given , and repeat. That is block Gibbs sampling, a Markov chain whose long-run distribution is the RBM's. Long-run is the problem: the chain can take a long time to forget where it started.
The two-state chain below shows the same idea. Make each state sticky and watch how long the path takes to settle.
AExplorable · A Markov chain playground
When tomorrow depends only on today, where does a process settle in the long run?
In the long run, what share of time does the chain spend in A?
The strip shows the first steps: state A in one color, B in the other. Long runs of one color mean a sticky chain.
Commit your prediction above to see the result
Make your prediction to see the result.
The R and Python versions of the reference program draw different random coins, so their sampled patterns differ even though the probabilities agree.
Contrastive divergence
ReadThe likelihood gradient for is a difference: the average of over the data minus its average under the model. The second average needs samples from the model, which needs a long chain.
Contrastive divergenceContrastive divergenceTrains an RBM with gradients from a few Gibbs steps started at the data, instead of from the model's true equilibrium. (CD-k) starts the chain at a data row and runs only Gibbs steps, often one. It is cheap and biased. The model can look good on what CD-1 measures, a one-step reconstruction, while its long-run samples are poor. Judge an RBM by its samples and by held-out likelihood estimates, not by reconstruction error.
Stacking: deep belief networks
ReadA deep belief networkDeep belief networkA stack of RBMs trained one layer at a time, with directed links down to the data and an undirected top pair of layers. trains one RBM on the data, then a second RBM on the first one's hidden activations, and so on. The result has directed links down toward the data and an undirected pair at the top. To generate, sample the top pair, then pass down layer by layer.
In the reference's example a top pattern passes down two layers: the middle layer's means are 0.574, 0.401 and 0.550. Greedy stacking was historically important as pretraining; today it is mostly a story about how deep networks got started.
Reference · DNN041 · Explained hereDeep belief network (DBN)A DBN combines an undirected top-level associative model with directed generative connections below it. Greedy RBM pretraining made deep representation learning practical historically;Fully undirected: deep Boltzmann machines
ReadA deep Boltzmann machineDeep Boltzmann machineA fully undirected stack of hidden layers; inference needs iterative mean-field updates because every layer talks to its neighbors. keeps every link undirected, so each hidden layer depends on the layers above and below. Exact inference is out of reach; a mean-field approximationMean-field approximationApproximates a joint posterior by independent factors, updating each from the others' current means until nothing changes. instead updates each layer's means from its neighbors' current means until nothing changes.
The reference runs those updates to a fixed point and checks it: the largest change left is 0.000. A fixed point is a local solution of the approximation, not the true posterior.
Reference · DNN042 · Explained hereDeep Boltzmann machine (DBM)A DBM stacks undirected interactions between neighboring layers, allowing bottom-up and top-down information to participate in inference.What runs here
ReadCheck: energy-based models
CheckpointCheck yourself
Why is an RBM's likelihood hard to compute exactly?
Show the answer
Answer: b
has a term for every configuration, exponentially many in the number of units. Conditional probabilities avoid it, which is why Gibbs steps are easy.
Check yourself
An RBM trained with CD-1 rebuilds rows very well after one Gibbs step. What can you conclude about its samples?
Show the answer
Answer: b
Contrastive divergence is cheap and biased. One-step reconstruction can look fine while the model puts mass in the wrong places.
Check yourself
Why can an RBM sample all its hidden units at once given the visible ones?
Show the answer
Answer: a
The restriction, no links within a layer, makes each layer's units conditionally independent given the other layer.
Check yourself
How is a deep belief network trained in the classic recipe?
Show the answer
Answer: b
Greedy layer-wise training: each new RBM models the previous layer's hidden activations. The stack can be fine-tuned afterwards.
Check yourself
How does a deep belief network generate a new row?
Show the answer
Answer: a
The top pair is an undirected RBM; below it, links point down toward the data, so a top-level sample is passed down one layer at a time.
Check yourself
A deep Boltzmann machine's mean-field updates reach a fixed point. What does that tell you?
Show the answer
Answer: b
Mean-field replaces the joint posterior with independent factors. A fixed point solves that approximation, possibly one of several solutions.
Check yourself
What distinguishes a deep Boltzmann machine from a deep belief network?
Show the answer
Answer: b
A DBN has directed links below its top pair. In a DBM all links are undirected, which is why inference needs iterative mean-field updates.
Recap
Recap- Energy models turn energies into probabilities, but the normalizer Z is usually intractable.
- An RBM samples one layer at a time; contrastive divergence trains it cheaply and with bias.
- A deep belief network stacks RBMs greedily; a deep Boltzmann machine is fully undirected and uses mean-field inference.
- Judge them by samples and held-out estimates, not by one-step reconstruction. All three are explained here.
Concepts in this lesson