Restricted Boltzmann machine

Also known as: RBM

On this page 7

A Restricted Boltzmann machine (RBM) is a two-layer, undirected generative model made of visible units that represent data and hidden units that capture features, with connections only between the two layers and none within a layer. Among neural networks, it belongs to the family of energy-based models: it assigns a scalar energy to every joint configuration of units and learns weights so that realistic data receives low energy and therefore high probability.

The restriction on connections is what makes the model practical. Because hidden units are conditionally independent given the visible layer, and vice versa, each layer can be sampled in a single parallel step. That property enabled efficient training with contrastive divergence and made RBMs the building block of deep belief networks, which helped revive deep learning in the mid-2000s.

How a Restricted Boltzmann machine defines probability

An RBM defines probability through an energy function over visible units v and hidden units h. For binary units, the energy is the negative sum of visible biases times visible states, hidden biases times hidden states, and the pairwise weights times the products of connected visible and hidden states. The joint probability is proportional to the exponential of the negative energy, divided by the partition function Z, which sums over all possible configurations.

The bipartite structure yields simple conditional distributions. The probability that a hidden unit turns on equals the logistic sigmoid of its bias plus the weighted sum of visible states, and the visible conditionals have the same form. This lets the model alternate between layers, a procedure known as block Gibbs sampling.

The table below lists the main components and their role.

ComponentSymbolRole in the model
Visible unitsvHold the observed data, such as pixels or ratings
Hidden unitshCapture latent features and dependencies
Weight matrixWConnects every visible unit to every hidden unit
Visible biasesbSet the baseline activity of each visible unit
Hidden biasescSet the baseline activity of each hidden unit
Partition functionZNormalizes energies into probabilities; intractable for large models
Components of a Restricted Boltzmann machine

Training with contrastive divergence

RBMs are trained to maximize the log-likelihood of the data, and the gradient for each weight is the difference between two correlations: the correlation of visible and hidden states when the visible layer is clamped to data, and the same correlation under the model distribution. The first term is easy to compute; the second requires samples from the model, which exact methods cannot provide efficiently.

Contrastive divergence (CD-k) approximates the model term by starting a Gibbs chain at a training example and running it for only k steps, often k = 1. The resulting gradient is biased but works well in practice. Persistent contrastive divergence keeps chains running across parameter updates, which gives samples closer to the model distribution and usually better generative quality.

MethodHow negative samples are obtainedMain trade-off
CD-1One Gibbs step from each data pointFast but strongly biased
CD-kk Gibbs steps from each data pointLess bias, more compute
Persistent CDChains continued across updatesBetter likelihood, needs small learning rate
Parallel temperingChains at several temperatures that swap statesMixes well, high cost
Common RBM training methods

Typical practical settings include learning rates around 0.01 to 0.1 for binary data, small random initial weights, mini-batches of tens to hundreds of examples, weight decay and momentum. Monitoring is difficult because the true likelihood depends on Z; practitioners track reconstruction error or estimate likelihood with annealed importance sampling, keeping in mind that reconstruction error can be misleading.

Unit types and RBM variants

The classic RBM uses binary visible and binary hidden units, but the energy function can be adapted to other data types. Choosing the right unit type is one of the main design decisions.

VariantVisible unitsTypical data
Bernoulli-Bernoulli RBMBinaryBinarized images, presence indicators
Gaussian-Bernoulli RBMReal-valued with Gaussian noiseAudio features, normalized pixels
Softmax or multinomial RBMCategorical groupsDiscrete ratings, word counts
Conditional RBMBinary or real, plus context inputsTime series, motion capture
Convolutional RBMImage patches with shared weightsLarger natural images
RBM variants by unit type

Gaussian visible units are notoriously harder to train and generally need lower learning rates and careful data normalization, because the variance parameters can make learning unstable.

An RBM is best understood as a simplified Boltzmann machine that trades expressiveness within a layer for tractable sampling. Its closest neighbors are the general Boltzmann machine, the Hopfield network, the autoencoder and the deep belief network.

ModelKey difference from an RBMPractical consequence
Boltzmann machineAllows connections within layersSampling is far slower
Hopfield networkDeterministic, no hidden unitsStores patterns rather than learning a distribution
AutoencoderDirected, trained by backpropagationNo explicit probability model
Deep belief networkStack of RBMs trained layer by layerDeeper feature hierarchies
RBM and neighboring models

In the greedy layer-wise pretraining scheme, each trained RBM’s hidden activations become the visible data for the next RBM. The stacked weights then initialize a deep feedforward network that is fine-tuned with backpropagation, an approach that was influential before better initialization, ReLU activations and normalization made pretraining largely unnecessary.

Applications, limitations and current relevance

RBMs found practical use in collaborative filtering, dimensionality reduction, feature learning, topic modeling and early speech recognition. In modern practice they have been largely superseded by variational autoencoders, generative adversarial networks, diffusion models and transformers, but they remain important in teaching and in physics-inspired research.

  • Intractable partition function: exact likelihood cannot be computed for realistic sizes.
  • Slow mixing: Gibbs chains can get stuck in one mode of the distribution.
  • Biased gradients: short chains in CD-1 can produce poor generative samples.
  • Sensitive hyperparameters: learning rate, hidden layer size and weight decay strongly affect results.
  • Active niche: RBMs are used as neural quantum states to represent many-body wave functions.

A plain-language summary

A Restricted Boltzmann machine is a simple network with two rows of switches. One row shows the data. The other row looks for hidden patterns. Switches in the same row never talk to each other. That rule makes the model fast to run.

Imagine a music service. The first row lists songs you liked. The second row learns tastes, such as calm jazz or loud rock. After training, the model can guess which new songs fit your taste. It learns what typical data looks like and can produce similar examples.

An example from practice

A mid-sized online film rental service wants better recommendations for about 50,000 subscribers who have each rated a small share of roughly 5,000 titles. The data team trains a softmax RBM in which every user is a separate training case, visible units encode the five possible star ratings for each rated film, and 100 hidden units capture taste profiles.

Weights are shared across users, and missing ratings are simply left out of each user’s visible layer. Training runs with CD-1 for the first epochs, then CD-3, with a learning rate of 0.01 and weight decay. To predict a rating, the team computes hidden activations from a user’s known ratings and reads the expected value of the target film’s visible units.

On a held-out set, the RBM alone performs similarly to a matrix factorization baseline, but blending the two models lowers prediction error further, because they capture different patterns. The service deploys the blend and retrains it weekly as new ratings arrive.