MathalyseResearch

Learn AI · Chapter 20 · Deep Generative Models

Boltzmann Machines for Real-Valued Data

Explain how Gaussian-Bernoulli RBMs model real-valued data through a conditional mean, why covariance models such as mcRBM, mPoT and the spike and slab RBM capture pixel relationships, and what each costs in sampling and in positive definiteness.

Book §20.5, pages 676–683Equations 20.38–20.53About 40 minutes
Section 1

Gaussian-Bernoulli RBMs

Binary pixels are a poor fit for natural images, so the book turns to models of real-valued data. The most common choice is an RBM with binary hidden units and real-valued visible units, where the visible units are Gaussian with a mean that depends on the hidden units. The book uses a precision formulation, in which the visible conditional is

real-valued visible units binary hidden units weights precision
(20.38)
Click any coloured symbol to see what it means.
Predict first

In a Gaussian-Bernoulli RBM, what sets the mean of the visible units?

How to use this page

Click any colored symbol in an equation or a sentence and it explains itself. Move the controls before you read the text under each demo, and try the question before the reveal.

One real-valued unit under two binary hidden units

Challenge +8 XP

Make the conditional standard deviation at most 0.5 for hidden state 1 0, so the precision must be at least 4.

conditional p(v | h)marginal p(v)

Only the terms that involve belong in the energy. Expanding the log of the Gaussian gives

(20.39)
Click any coloured symbol to see what it means.

The term collects everything that depends only on the parameters, and the normalizer absorbs it. The expansion also contains a term that couples pairs of hidden units, . Including it would turn the model into a linear factor model, so the book omits the pairs and keeps the energy an RBM. Each single hidden unit still gets a term, equation 20.41, which is optional and changes the learning dynamics.

(20.40)
Click any coloured symbol to see what it means.
(20.41)
Click any coloured symbol to see what it means.

With the precision matrix diagonal, the energy of the model is

(20.42)
Click any coloured symbol to see what it means.

The demo uses one real-valued visible unit, two binary hidden units and a bias for each hidden unit. The dashed curve is the conditional density for the state you chose. The solid purple curve is the marginal density, which adds up every hidden state.

Section 2

Conditional covariance with mcRBM and mPoT

The Gaussian RBM only models the conditional mean of the input. Ranzato and colleagues argue that natural images carry much of their information in the covariance between pixels, so a model with a fixed covariance misses it. The mean and covariance RBM (mcRBM) splits its hidden layer into mean units and covariance units. The mean units form a Gaussian RBM, and the covariance units form a covariance RBM. The energy is the sum of the two parts:

(20.43)
Click any coloured symbol to see what it means.
(20.44)
Click any coloured symbol to see what it means.
(20.45)
Click any coloured symbol to see what it means.
Predict first

In mcRBM, what does a covariance unit that is on do to the variance along its direction?

The joint distribution and the conditional over the observations follow. The conditional is a multivariate Gaussian whose covariance is not diagonal, so the covariance units control how the pixels co-vary:

(20.46)
Click any coloured symbol to see what it means.
(20.47)
Click any coloured symbol to see what it means.

Sampling the observations given the hidden units would need the inverse of at every step, which is expensive. Training uses hybrid Monte Carlo on the marginal instead. The mean-product of Student's t-distributions (mPoT) model follows the same pattern, with Gamma distributions over the covariance units in place of binary units:

(20.48–20.49)
Click any coloured symbol to see what it means.

How covariance units reshape the conditional

Challenge +8 XP

Turn on covariance unit 1 and make the variance along its direction at most 0.3.

Each active covariance unit adds a term along its direction to the precision. The variance along that direction then shrinks, which is what the energy in equation 20.45 asks for. The demo draws the resulting ellipse.

Section 3

The spike and slab RBM

The spike and slab RBM (ssRBM) also models covariance, with a different mechanism. It has two sets of hidden units. The binary spike units decide whether a component appears, and the real-valued slab units set its intensity. The mean of the visible units is , and when a spike is active, its slab adds variance along the matching column. Its energy has the form

(20.50)
Click any coloured symbol to see what it means.
(20.51)
Click any coloured symbol to see what it means.

where is the offset of spike , is a diagonal precision on the observations, is a scalar precision for slab , is a nonnegative diagonal penalty, and is the slab mean. Marginalizing out the slabs gives a Gaussian over the observations:

Predict first

In the ssRBM, what happens to the variance along column W(i) when spike h(i) turns on?

(20.52)
Click any coloured symbol to see what it means.
(20.53)
Click any coloured symbol to see what it means.

The matrix is the inverse of a sum that subtracts for each active spike. That is why turning a spike on widens the distribution along its component. The book notes that is a valid covariance only when this matrix is positive definite, and that some parameter settings break this condition.

Spike components and the positive definite check

Challenge +8 XP

Turn on both spike units and choose the components so the matrix stops being positive definite.

The demo sets the observation precision to the identity and the penalty to zero, so only the spike terms change the covariance. The ellipse is the covariance when the precision is positive definite. When it is not, the book's warning applies, and the density has no finite normalizer.

Section 4

The cost of covariance

The three covariance models differ in what they need at each step. The mcRBM and mPoT conditionals need the inverse of a dense covariance, and their training depends on hybrid Monte Carlo. The ssRBM needs no matrix inversion, and contrastive divergence and persistent contrastive divergence with Gibbs sampling still apply. The ssRBM pays with the positive definiteness condition, which the book says has no fully satisfying solution yet. Convolutional ssRBMs produce good natural image samples.

How the work grows with the number of values

Challenge +8 XP

Set the number of values so that inverting a dense covariance costs at least 1000 times more than a diagonal precision.

The comparison is an order of magnitude estimate, not a timing. Inverting a dense matrix takes work on the order of . Applying a diagonal precision takes work on the order of . Their ratio is , which is why dense covariance models are hard to sample at image sizes.

What to take away
  • A Gaussian-Bernoulli RBM has a conditional mean and a precision that can be fixed or learned. It is a natural first model for real-valued data.
  • mcRBM and mPoT model the conditional covariance with covariance units, but sampling needs a dense inverse and hybrid Monte Carlo.
  • The ssRBM models covariance with spike and slab units, avoids the inverse, and needs the positive definite condition to hold.
  • The spike units widen the distribution along their component, and the covariance units shrink it along their direction.
Final quiz

Check yourself

Questions that mix the whole module. Each one is scored, and the score feeds your mastery of this module.

Source: Ian Goodfellow, Yoshua Bengio and Aaron Courville, Deep Learning, MIT Press, 2016, Section 20.5 (pages 676–683), free to read at deeplearningbook.org. Where the book prints equation numbers, the numbers here follow the book. The order of ideas follows the book. The explanations and all demos were written for this page.