§16.5–16.7.1Learning Dependencies · Inference · The Deep Learning Approach · the RBM

Part III DL pp. 582–589 · ~10 min read

  • structure learning
  • loopy belief propagation
  • restricted boltzmann machine (rbm)
  • block gibbs sampling

§16.5 Learning about dependencies

A good generative model must capture the distribution over the visible variables v\boldsymbol{v}, whose elements are usually highly dependent on one another. There are two ways to model those dependencies. The traditional way is structure learning : search — usually greedily — over graph structures, training and scoring each (accuracy minus a complexity penalty), adding and removing edges. The deep-learning way is to introduce latent (“hidden”) variables h\boldsymbol{h} and connect every visible to them, so that any two visibles interact indirectly through h\boldsymbol{h} — no direct visible–visible edges, no discrete structure search:

Two ways to model dependent visibles. Left: direct connections force a large clique over v (many parameters, hard to estimate). Right: a layer of latent h captures the same dependencies indirectly — v₁,v₂,v₃ interact only through h, a fixed structure whose parameters are simply learned.
direct — a big clique over vv₁v₂v₃latent — decoupled through hh₁h₂v₁v₂v₃

Latent variables earn their keep twice over. Beyond capturing p(v)p(\boldsymbol{v}) cheaply, h\boldsymbol{h} is itself an alternative representation of v\boldsymbol{v}: as with the mixture of Gaussians (whose latent component index classifies the input) or sparse coding, the learned E[hv]\mathbb{E}[\boldsymbol{h} \mid \boldsymbol{v}] or argmaxhp(h,v)\arg\max_{\boldsymbol{h}} p(\boldsymbol{h}, \boldsymbol{v}) makes an excellent feature vector — feature learning is latent- variable learning.

§16.6 Inference and approximate inference

We constantly need to answer questions like “given these visibles, what are the latents?” — to extract features E[hv]\mathbb{E}[\boldsymbol{h}\mid\boldsymbol{v}], or to train by maximum likelihood, which needs p(hv)p(\boldsymbol{h}\mid\boldsymbol{v}):

Why inference is unavoidable (eq 16.9)

logp(v)=Ehp(hv) ⁣[logp(h,v)logp(hv)]\log p(\boldsymbol{v}) = \mathbb{E}_{\boldsymbol{h} \sim p(\boldsymbol{h} \mid \boldsymbol{v})}\!\left[\log p(\boldsymbol{h}, \boldsymbol{v}) - \log p(\boldsymbol{h} \mid \boldsymbol{v})\right]
p(hv)p(\boldsymbol{h} \mid \boldsymbol{v})the POSTERIOR over latents given the data — needed both to take the expectation and inside the bracket. Computing it is the inference problemdistribution over h
logp(h,v)\log p(\boldsymbol{h}, \boldsymbol{v})the joint, which the model defines directly (e.g. via an energy). The easy partscalar
Ehp(hv)\mathbb{E}_{\boldsymbol{h} \sim p(\boldsymbol{h}\mid\boldsymbol{v})}to even evaluate the log-likelihood we must average under the posterior — so a learning rule is built on inferenceexpectation

For most interesting deep models this inference is intractable, even with a graph: the graphs used in deep learning are expressive but not restrictive enough to permit efficient exact inference.

Just how hard? #P-hard.

Computing the marginal probability of a general graphical model is #P-hard — the counting analogue of NP (where NP asks whether a solution exists, #P asks how many do). Encode a 3-SAT formula as a graphical model with one latent per clause and a reduction tree of “all satisfied?” latents; the marginal at the root then reports what fraction of assignments satisfy the formula. Such worst cases — and NP-hard graphs — arise in real problems, which is why we turn to approximation.

In deep learning that approximation is almost always variational inference: replace the true posterior p(hv)p(\boldsymbol{h}\mid\boldsymbol{v}) with a tractable q(hv)q(\boldsymbol{h}\mid\boldsymbol{v}) chosen as close to it as possible — the whole subject of chapter 19.

§16.7 The deep-learning approach to graphical models

Deep learning uses the same graphical-model tools as everyone else, but makes systematically different design choices — so different that the resulting models have their own flavor:

Traditional graphical models vs the deep-learning style. Click a cell for detail.
DimensionTraditional graphical modelsDeep learning
Latent variableshow many, and whyfew, mostly observed variablesmany — usually MORE latents than observed
Latent semanticsmeaning of a latentdesigned with a specific meaningunspecified — the algorithm invents them
Connectivityhow nodes connectfew, individually designed edgesdense group-to-group via a matrix
Inference algorithmhow questions are answeredexact inference, or loopy belief propagationGibbs sampling or variational inference
Graph depthwhat "deep" meansshallow graphsshallow GRAPH, deep computation
Dotted-underlined cells have explanations — click one.

Tolerance of the unknown

The defining attitude: rather than simplify the model until everything is exactly computable, deep learning increases the model’s power until it is just barely trainable. We routinely use models whose marginals cannot be computed and are content to draw approximate samples; we train with objective functions we cannot even evaluate, as long as we can efficiently estimate their gradient. Figure out the minimum information you truly need — then approximate that, fast. Loopy belief propagation , a staple elsewhere, is almost never used here.

§16.7.1 Example: the restricted Boltzmann machine

The restricted Boltzmann machine (RBM), or harmonium (Smolensky, 1986), is the quintessential deep-learning graphical model. It is not itself deep — it has a single latent layer — but it is the building block of many deeper models (chapter 20), and it exemplifies every practice above: units in layers, connectivity by a matrix, relatively dense, designed for efficient Gibbs sampling, latent semantics left to the training algorithm. It is an energy-based model with binary visible and hidden units:

The RBM energy (eq 16.10)

E(v,h)=bvchvWhE(\boldsymbol{v}, \boldsymbol{h}) = -\boldsymbol{b}^\top \boldsymbol{v} - \boldsymbol{c}^\top \boldsymbol{h} - \boldsymbol{v}^\top \boldsymbol{W} \boldsymbol{h}
bv-\boldsymbol{b}^\top \boldsymbol{v}visible biases: b sets each visible unit's baseline tendency to be onb ∈ ℝⁿ_v
ch-\boldsymbol{c}^\top \boldsymbol{h}hidden biases: c sets each hidden unit's baselinec ∈ ℝⁿ_h
vWh-\boldsymbol{v}^\top \boldsymbol{W} \boldsymbol{h}the ONLY interaction term: a single weight matrix couples every visible to every hidden — and there are no v–v or h–h termsW ∈ ℝ^{n_v×n_h}

The energy has no visible–visible or hidden–hidden term — that is the “restricted” (a general Boltzmann machine allows arbitrary connections). Drawn as a Markov network it is bipartite:

Fig 16.14 — an RBM as a Markov network. Every hidden connects to every visible (via W), but no two units in the same layer connect. That restriction is exactly what makes the layer-wise conditionals factorial.
h₁h₂h₃h₄v₁v₂v₃hv

Because no unit shares a layer with a unit it depends on, the layer-wise conditionals factorizep(hv)=ip(hiv)p(\boldsymbol{h}\mid\boldsymbol{v}) = \prod_i p(\mathrm{h}_i\mid\boldsymbol{v}) (eq 16.11) and likewise for p(vh)p(\boldsymbol{v}\mid\boldsymbol{h}) (eq 16.12) — and each individual conditional is just a sigmoid:

The RBM hidden-unit conditional (eq 16.13, as printed)

P(hi=1v)=σ ⁣(vW:,i+bi)P(\mathrm{h}_i = 1 \mid \boldsymbol{v}) = \sigma\!\left(\boldsymbol{v}^\top \boldsymbol{W}_{:,i} + b_i\right)
vW:,i\boldsymbol{v}^\top \boldsymbol{W}_{:,i}the total input to hidden unit i: the visible vector dotted with W's i-th column (unit i's incoming weights)scalar
bib_ithe bias of hidden unit i. NOTE the book's local notation clash: this is the hidden bias written c in eq 16.10 — here eq 16.13 prints it as bᵢscalar
σ()\sigma(\cdot)the logistic sigmoid → a probability in (0,1). Every hidden unit turns on independently given v, so the whole layer samples at onceprobability

Worked example — one sigmoid conditional

Take hidden unit 1 with incoming weights W:,1=(1.3, 0.8, 1.0)\boldsymbol{W}_{:,1} = (1.3,\ 0.8,\ -1.0) and bias 0.2-0.2, and visibles v=(1,0,1)\boldsymbol{v} = (1, 0, 1). Then vW:,1=1(1.3)+0(0.8)+1(1.0)=0.3\boldsymbol{v}^\top\boldsymbol{W}_{:,1} = 1(1.3) + 0(0.8) + 1(-1.0) = 0.3, plus the bias gives 0.10.1, so P(h1=1v)=σ(0.1)0.52P(\mathrm{h}_1 = 1\mid\boldsymbol{v}) = \sigma(0.1) \approx 0.52 — a near coin-flip. Change v\boldsymbol{v} and the probability slides; that is exactly what the sampler below computes for every unit.

Together, the factorial conditionals enable block Gibbs sampling : sample all of h\boldsymbol{h} at once from v\boldsymbol{v}, then all of v\boldsymbol{v} at once from h\boldsymbol{h}, alternating. Step it:

Block Gibbs sampling in a small RBM. Each "sample" draws a WHOLE layer at once — every hidden unit from its sigmoid P(hᵢ=1|v), then every visible from P(vⱼ=1|h). The no-intra-layer restriction is what makes each layer conditionally independent, so a block updates in one shot. This is the sampler used to train RBMs (chapter 18).
h1P=0.52h2P=0.49v1P=0.55v2P=0.43v3P=0.52hv
step 0 · v = [1, 0, 1] · h = [0, 0]
next: sample the HIDDEN block from P(hᵢ=1 | v)

No hidden–hidden or visible–visible edges means every unit in a layer is conditionally independent of the rest of its layer given the other layer — so the whole block samples at once, each unit from a simple sigmoid. Alternating h, v, h, v… is block Gibbs sampling, and it is what makes the RBM cheap to train (ch18).

Finally, because the energy is linear in the parameters, its derivatives are trivial — e.g. Wi,jE(v,h)=vihj\frac{\partial}{\partial W_{i,j}} E(\boldsymbol{v},\boldsymbol{h}) = -\mathrm{v}_i \mathrm{h}_j (eq 16.15). Efficient block Gibbs sampling and efficient derivatives are exactly what make the RBM convenient to train (chapter 18 shows how undirected models are trained from such derivatives on model samples). Training induces a representation h\boldsymbol{h}; Ehp(hv)[h]\mathbb{E}_{\boldsymbol{h}\sim p(\boldsymbol{h}\mid\boldsymbol{v})} [\boldsymbol{h}] serves as features for v\boldsymbol{v}.

The RBM thus distills the whole deep-learning approach to graphical models: representation learning through layers of latent variables, with efficient matrix-parametrized interactions between layers. With this language in hand, the chapters ahead describe a wide variety of deep probabilistic models.

Check yourself — latent variables, inference & the RBM

1.How does deep learning capture dependencies among visible variables, instead of using structure learning?

2.Why does maximum-likelihood training force us to confront inference?

3.Why is loopy belief propagation almost never used in deep learning?

4.What makes an RBM 'restricted', and why does it matter?

5.Predict the outcome — in BlockGibbsLab with v = (1,0,1), you click 'sample the hidden block'. What is computed for each hidden unit?

5 questions