Restricted Boltzmann Machine (RBM)

Machine Learning
Introduced by
Smolensky, P. (1986); popularised by Hinton, G. E. & Salakhutdinov, R. R. (2006)
Year
1986
Type
Generative energy-based probabilistic model

What does it do?

A Restricted Boltzmann Machine (RBM) is a two-layer generative model with binary visible (observed) and hidden (latent) units, connected by an undirected bipartite graph with no connections within either layer.

Smolensky introduced the architecture in 1986 under the name 'Harmonium'. Contrastive Divergence was introduced by Hinton (2002) for training Products of Experts and is now the standard training procedure for RBMs. RBMs are best known as building blocks of Deep Belief Networks.

The intuition behind the method

Picture a two-sided panel. One side holds the observed data, such as the pixel intensities of an image; the other side holds hidden units that try to explain it. Every hidden unit is connected to every visible unit, but units on the same side are not connected to each other. Training adjusts the connection weights so that the model assigns high probability to the observed data. The approximate learning procedure does this by comparing how often a visible and a hidden unit switch on together for the data with how often they do so in the model's own samples. Once trained, the hidden activations give a compact, distributed description of the inputs.

History

Smolensky proposed the architecture in 1986 under the name 'Harmonium' as part of his harmony theory framework. The model attracted limited attention until Hinton (2002) introduced Contrastive Divergence, a training objective whose gradients can be approximated efficiently and which made training of RBMs practical. Hinton and Salakhutdinov (2006) reported an effective weight-initialisation method for deep autoencoders that yields low-dimensional codes working much better than PCA; the stacked-RBM pre-training of Deep Belief Networks is a related line of work.

When to use it

Choose an RBM when you want an unsupervised model of a binary data distribution, when you want hidden units that capture a compact distributed representation, or when you need a layer-wise pre-training stage for a deeper network such as a Deep Belief Network. Gaussian-visible variants extend the choice to real-valued inputs, with the stability caveats discussed below. Do not choose an RBM when the data has strong sequential or temporal structure, because the standard model treats each data vector independently and has no mechanism for order. Do not choose it as a default generator for high-quality sampling, since VAEs, GANs and diffusion models now dominate that role. Avoid it when you need exact likelihood values, because the partition function makes them intractable.

Limitations and considerations

  • The partition function Z is intractable for networks of realistic size, so exact log-likelihood and exact gradients are not available.
  • Contrastive Divergence is a biased estimator of the maximum-likelihood gradient, and CD-1 in particular does not in general converge to the maximum-likelihood solution.
  • Training depends on the learning rate, the number of hidden units and the number of CD steps, so results can vary with these settings.
  • The canonical formulation uses binary visible units. Gaussian-visible variants support real-valued inputs but are generally less stable to train and need careful input normalisation.
  • For most modern generative and representation-learning tasks, VAEs, GANs and diffusion models have largely replaced RBMs.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • The bipartite structure makes the conditional distributions factorise, so all hidden units can be sampled together given the visible layer, and vice versa. This is what makes block Gibbs sampling practical.
  • Contrastive Divergence gives a cheap, approximate gradient using only a few Gibbs steps started from a data point, so training does not require sampling the model to equilibrium.
  • The hidden layer gives each input a distributed binary code that can be used as features for downstream tasks.
  • Stacking RBMs and training them one layer at a time is the procedure that gives Deep Belief Networks their name and their pre-training role.
  • The energy function defines one explicit score for every joint configuration, which makes the model's preferences straightforward to inspect.

Applications

  • Greedy layer-wise pre-training of Deep Belief Networks.
  • Unsupervised feature learning, where hidden activations serve as inputs to a supervised classifier.
  • Modelling the distribution of binary data vectors.
  • Physics-inspired machine learning, where the energy-based formulation is used to model systems of interacting binary variables.

How it works

How it works

1

The RBM assigns a scalar energy to every joint configuration (v, h) of visible and hidden units. The energy has three terms: visible biases (b), hidden biases (c), and a weight matrix W that couples each visible unit with each hidden unit. Configurations with low energy are the ones the model considers more probable.

Formula
E(\mathbf{v}, \mathbf{h}) = -\mathbf{b}^\top \mathbf{v} - \mathbf{c}^\top \mathbf{h} - \mathbf{v}^\top \mathbf{W} \mathbf{h}
2

The joint probability of a configuration is proportional to the exponential of its negative energy, normalised by the partition function Z, which sums over all visible-hidden configurations. Z cannot be computed exactly for networks of realistic size, so the parameters cannot be fitted by exact maximum likelihood.

Formula
P(\mathbf{v}, \mathbf{h}) = \frac{e^{-E(\mathbf{v},\mathbf{h})}}{Z}, \quad Z = \sum_{\mathbf{v},\mathbf{h}} e^{-E(\mathbf{v},\mathbf{h})}
3

Because there are no connections within a layer, the hidden units are conditionally independent given the visible vector. The probability that hidden unit j is on is a sigmoid of its bias plus the weighted sum of the visible inputs. This property allows all hidden units to be sampled in one step.

Formula
P(h_j = 1 \mid \mathbf{v}) = \sigma\!\left(c_j + \sum_i W_{ij}\, v_i\right)
4

By the same argument, visible units are conditionally independent given the hidden vector. Each visible unit is on with a probability given by a sigmoid of its bias plus the weighted sum of the hidden inputs. Alternating between these two conditionals is block Gibbs sampling, which is used to draw approximate samples from the model.

Formula
P(v_i = 1 \mid \mathbf{h}) = \sigma\!\left(b_i + \sum_j W_{ij}\, h_j\right)
5

Exact maximum-likelihood training needs expectations under the model distribution, which are intractable. Contrastive Divergence (CD-k), introduced by Hinton (2002), replaces the model expectation with statistics from k steps of block Gibbs sampling started at a data point. The weight update is the learning rate times the difference between the data-driven and the model-driven co-activation of each visible-hidden pair; in practice the model term is the k-step Gibbs estimate, not the exact expectation.

Formula
\Delta W_{ij} = \eta\left(\langle v_i h_j \rangle_{\text{data}} - \langle v_i h_j \rangle_{\text{model}}\right)

Common pitfalls

  • Using CD-1 and assuming it approximates maximum likelihood well. Larger k or persistent CD (PCD) gives less biased gradient estimates, at higher computational cost.
  • Choosing the number of hidden units without validation. Too few hidden units underfit, while too many can overfit and slow the mixing of the Gibbs chain.
  • Relying on reconstruction error alone to judge convergence. It is a rough proxy and does not measure the likelihood, so it should be monitored alongside weight norms and hidden-unit activity.
  • Feeding unnormalised real-valued data to a Gaussian-visible RBM. Inputs should be centred and scaled first.
  • Treating an RBM as a first-choice generative model for modern tasks without comparing it to more capable alternatives.

Frequently asked questions

What makes an RBM 'restricted'?

The restriction is the absence of connections within the visible layer and within the hidden layer. Only connections between the two layers are allowed, forming a bipartite graph. This restriction makes inference tractable: all hidden units are conditionally independent given the visible units, and vice versa, which allows whole layers to be sampled at once.

How does Contrastive Divergence work and why is it approximate?

CD-k starts from a training data point, runs k steps of alternating Gibbs sampling, and uses the resulting sample as an approximate stand-in for a sample from the model distribution. The exact gradient of the log-likelihood needs expectations under the model distribution, which would require running the chain close to equilibrium. With small k the estimate is biased, but it is cheap and often works well in practice.

Can RBMs handle continuous data?

The standard RBM uses binary visible and hidden units. A Gaussian-visible RBM keeps the bipartite connectivity but treats the visible units as real-valued: the visible conditional becomes a Gaussian distribution centred on the same weighted sum of hidden inputs plus the visible bias, in place of a sigmoid. The hidden units typically remain binary. Training Gaussian-visible RBMs is less stable than the binary case and requires careful normalisation of the inputs.

Are RBMs still used in modern deep learning?

Rarely as a front-line method for generation or representation learning, where VAEs, GANs and diffusion models now dominate. RBMs remain in use in physics-inspired machine learning, for example for systems of interacting binary variables, and they are a clear example of an energy-based probabilistic model for teaching.

Related methods

Sources

  1. Hinton, G. E., & Salakhutdinov, R. R. (2006). Reducing the Dimensionality of Data with Neural Networks. Science, 313(5786), 504–507.

    Open DOI reference
  2. Hinton, G. E. (2002). Training Products of Experts by Minimizing Contrastive Divergence. Neural Computation, 14(8), 1771–1800.

    Open DOI reference
  3. Smolensky, P. (1986). Information Processing in Dynamical Systems: Foundations of Harmony Theory. In D. E. Rumelhart & J. L. McClelland (Eds.), Parallel Distributed Processing, Vol. 1 (pp. 194–281). MIT Press.

    ISBN: 978-0-262-68053-0
  4. Goodfellow, I., Bengio, Y., & Courville, A. (2016). Deep Learning (Ch. 20). MIT Press.

    ISBN: 978-0-262-03561-3