MathalyseResearch

Learn AI · Chapter 20 · Deep Generative Models

Generative Stochastic Networks

Build a generative chain from a latent state and a visible state, check when its spread settles with a linear toy, train it on the clamped reconstruction log-probability, and see how a discriminant variant reuses the same chain.

Book §20.12, pages 714–716About 30 minutes
Section 1

The latent state in the chain

Section 20.11 ran a chain that moves only the visible variables. The generative stochastic network, or GSN, adds latent variables to the chain, next to the visible variables . The book describes a GSN as a generalization of a denoising autoencoder. It keeps the same idea: the model is specified by the steps of the chain, and not by a written-out joint distribution.

the visible state , the latent state and the distributions , noise draws the noise size
How to use this page

Click any colored symbol in an equation or a sentence and it explains itself. Answer each prediction before you press the buttons, then move the controls and watch the traces.

Two conditional distributions specify one step of the chain. The book gives them as follows.

  1. tells how to generate the next visible variable given the current latent state. This is the reconstruction distribution, which also appears in denoising autoencoders, RBMs, DBNs and DBMs.
  2. tells how to update the latent state, given the previous latent state and the previous visible variable.
Click any coloured symbol to see what it means.

A GSN does not write down the joint distribution of the visible and latent variables. The joint is defined implicitly, if it exists, as the stationary distribution of the generative chain. The conditions for a stationary distribution are the standard MCMC conditions. They can fail for some choices of the transition distributions, for example when the transitions are deterministic.

Predict first

Which object does a GSN define directly, as its own specification?

Latent and visible states over steps

latent state hvisible state x

The traces start both states at 3. Move the number of steps and read the readout, which splits each new value into its weighted part and its noise. The latent state is never shown in the data. The chain carries it from one step to the next, so the visible state depends on the past through . The toy uses linear maps with Gaussian noise, which the book does not require. The equation below is not in the book:

Click any coloured symbol to see what it means.
Section 2

Two conditionals and their stationary spread

Stack the pair and into one vector. Then one step of the toy is a matrix applied to the previous pair, plus noise with covariance . The matrix has rank one, so one eigenvalue is 0 and the other is . The spectral radius therefore decides whether the chain settles:

Click any coloured symbol to see what it means.

When is below 1, the covariance of the pair settles to a fixed value, the stationary covariance. Its equation is written below, and the variance of the visible state is the (2,2) entry. When is 1 or more, no fixed value exists.

Click any coloured symbol to see what it means.

The demo settles the covariance by repeating the update, which converges when is below 1. It then checks the answer against 2000 simulated chains.

Predict first

With a = 0.9, b = 0.3 and c = 1, the spectral radius is 1.2. What does the visible state do over many steps?

Does the chain settle?

visible state xlatent state hone stationary standard deviation (dashed)
Challenge +8 XP

Keep the chain convergent, with below 1, and make the stationary variance of at least 2.

Challenge +8 XP

Make larger than 1, so that the chain has no stationary distribution.

Press Oscillation case to set a = −1, b = 0, c = 1 and = 0. Here = 1. The state flips sign at every step and never settles, which is the boundary of the rule. A value of above 1 is a different failure: the state grows, and the chain has no stationary distribution at all. Raise the noise and the spread grows without limit, because at this boundary no stationary covariance exists.

Section 3

Reconstruction log-probability criterion

The training criterion that Bengio et al. (2014) proposed and evaluated is the reconstruction log-probability on the visible units, as for denoising autoencoders. The chain is clamped at a training example, . The model then maximizes the log-probability that the visible unit generates at a later step , where the latent state is sampled from the chain given the clamped start. The book says the gradient is estimated with the reparametrization trick of section 20.9, and that the walk-back procedure of section 20.11.3 is used to improve convergence.

Predict first

The clamped example is x* = 1.5. Why is the reconstruction log-probability at step 1 higher than its value after many steps?

The book gives the criterion in words, and it does not write out the toy's value. The equation below is a toy form, in which the reconstruction distribution is Gaussian with the same noise size as the chain. The average is taken over the chains at each step:

Click any coloured symbol to see what it means.

Reconstruction log-probability over steps

mean log-probability at step kstationary value (dashed)
Challenge +8 XP

Keep below 1 and make the mean reconstruction log-probability at step 1 at least −1.

At step 1 the chain has moved only a little from the example, so the latent state still reflects it and the log-probability is high. As the steps go on, the chain forgets the example and the curve moves towards its stationary value. When is above 1 the curve has no such value, and it falls without limit. That is the same failure as in section 2, now seen through the training criterion. The book says the training criterion is about the visible units, so the demo measures the reconstruction of and nothing else.

Section 4

Discriminant GSNs

The original GSN was meant for unsupervised learning, and it models for observed data . The framework can also model a conditional . Zhou and Troyanskaya (2014) generalize GSNs in this way. They back-propagate the reconstruction log-probability over the output variables only and keep the inputs fixed. They applied it to protein secondary structure, with a one-dimensional convolutional structure in the transition operator.

The Markov chain is then over the output, and the input sequence only conditions it. The book calls this a case of structured outputs. Zöhrer and Pernkopf (2014) go a step further and combine the two objectives. They add a supervised cost and an unsupervised cost with different weights, which are the reconstruction log-probabilities of y and of x. Larochelle and Bengio (2008) had introduced this hybrid criterion for RBMs, and Zöhrer and Pernkopf report improved classification with it.

The toy below uses two quadratic costs, which are not in the book, to show how the weight moves the best parameter. The supervised cost prefers and the unsupervised cost prefers . The total cost is their weighted sum:

Click any coloured symbol to see what it means.
Predict first

The weight on the supervised cost is 0.2. Where is the best parameter?

Hybrid weight and the best parameter

supervised cost (dashed)unsupervised costtotal cost
Challenge +8 XP

Set the weight so that the best parameter is exactly = 1.

The total cost is lowest at , which is in the toy. A small weight on the supervised cost pulls the best value towards 0, and a large weight pulls it towards 2. The book does not give this toy, so the numbers come from the formula above and not from a trained model.

Summary

Keep these facts. Each one has a demo above that you can check.

  • A GSN is a Markov chain with two conditionals, the reconstruction distribution and the latent update . Its joint distribution is implicit, as the stationary distribution of the chain.
  • In the linear toy the chain settles when is below 1. At 1 or above, the spread has no fixed value.
  • Training maximizes the reconstruction log-probability of a clamped example at step . Early steps stay near the example, and the average moves towards its stationary value as the chain forgets it.
  • Discriminant GSNs back-propagate the reconstruction log-probability over the outputs only. The hybrid weight, in the toy, sets where the best parameter sits.
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.12 (pages 714–716), 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.