§16.2.1–16.2.3Directed Models · Undirected Models · The Partition Function

Part III DL pp. 563–568 · ~8 min read

  • bayesian network
  • markov random field
  • clique potential
  • partition function
  • gibbs distribution

§16.2.1 Directed models — one arrow, one conditional

A directed graphical model — also called a belief network or Bayesian network (Pearl, 1985) — uses directed edges. An arrow from aa to bb means we define bb‘s distribution conditionally on aa: aa appears on the right of the conditioning bar. The relay race is the natural example — Bob’s time is defined given Alice’s, Carol’s given Bob’s:

Fig 16.2 — the relay race as a directed model. Click a node to see every factor it appears in: its own conditional, plus the conditionals it parents.
t₀t₁t₂
p(t0,t1,t2)=p(t_0, t_1, t_2) =p(t0)p(t_0)p(t1t0)p(t_1 \mid t_0)p(t2t1)p(t_2 \mid t_1)

click a node to see which factors mention it

Formally, a directed model is a directed acyclic graph G\mathcal{G} plus one local conditional per node, and the joint is their product:

The directed factorization (eq 16.1)

p(x)=ip ⁣(xiPaG(xi))p(\boldsymbol{x}) = \prod_i p\!\left(\mathrm{x}_i \mid Pa_{\mathcal{G}}(\mathrm{x}_i)\right)
p(xiPaG(xi))p(\mathrm{x}_i \mid Pa_{\mathcal{G}}(\mathrm{x}_i))the local conditional of node i given its PARENTS — a small table (or formula) attached to that nodeone factor per node
PaG(xi)Pa_{\mathcal{G}}(\mathrm{x}_i)the parents of xᵢ: the nodes with an arrow INTO xᵢ. Few parents → few parameterssubset of nodes
i\prod_ithe joint is exactly the product of these local conditionals — nothing else to specifyover all n nodes

For the relay race this reads p(t0,t1,t2)=p(t0)p(t1t0)p(t2t1)p(t_0, t_1, t_2) = p(t_0)\,p(t_1 \mid t_0)\,p(t_2 \mid t_1) — no t0t_0 term inside t2t_2‘s factor, because Carol depends on Alice only through Bob.

The cost win, formally. Discretize each time into 100 buckets. The full joint table needs 10031=999,999100^3 - 1 = 999{,}999 values; the three conditional tables need 99+9900+9900=19,89999 + 9900 + 9900 = 19{,}899 — a 50× saving. In general a full table is O(kn)O(k^n) while a directed model is O(km)O(k^m), where mm is the most variables in any single conditional. As long as mnm \ll n the savings are dramatic. (Slide it yourself in the ParamBlowupLab of §16.1.) Restricting the graph further — e.g. to a tree — additionally makes marginals and conditionals efficient to compute.

The graph encodes independence — nothing else

The graph says only which variables are conditionally independent. Other simplifying assumptions live inside the conditional’s definition. Suppose Bob’s personal running time is independent of Alice — then t1t_1 is just t0t_0 plus Bob’s own time, an O(k)O(k) formula instead of an O(k2)O(k^2) table. Yet we still need the t0t1t_0 \to t_1 arrow, because t1t_1 is Bob’s absolute finish time, which does depend on when Alice handed off. The directed syntax constrains only which variables a conditional may take as arguments — never how you define it.

§16.2.2 Undirected models — affinities, not conditionals

When interactions have no natural direction, use an undirected model , also called a Markov random field (MRF) or Markov network (Kindermann, 1980). Its edges carry no arrows and no conditional distributions. Consider three people’s health: you (hyh_y), your roommate (hrh_r), your coworker (hch_c). You can infect either of them and be infected by either — symmetric, so no arrows. But your roommate and coworker never meet, so there is no direct edge between them; they influence each other only through you:

Fig 16.3 — the cold-spreading undirected model. Roommate and coworker connect only through you; click a node to see which clique factors involve it.
hᵣh_yh_c
p~(hr,hy,hc)=\tilde{p}(h_r, h_y, h_c) =ϕr,y(hr,hy)\phi_{r,y}(h_r, h_y)ϕy,c(hy,hc)\phi_{y,c}(h_y, h_c)

click a node to see which factors mention it

For each clique (a set of mutually connected nodes) a non-negative factor ϕ(C)\phi(C) — a clique potential — scores how much its variables “like” being in each joint state. Their product is an unnormalized distribution:

The undirected factorization (eq 16.3)

p~(x)=CGϕ(C)\tilde{p}(\boldsymbol{x}) = \prod_{C \in \mathcal{G}} \phi(C)
ϕ(C)\phi(C)the clique potential: a NON-NEGATIVE affinity for each joint state of the clique C — higher = more likely. Not a probabilitytable over clique states
p~(x)\tilde{p}(\boldsymbol{x})the UNNORMALIZED probability (note the tilde) — a product of affinities; efficient to evaluate when every clique is smallscalar ≥ 0
CG\prod_{C \in \mathcal{G}}product over cliques. Unlike a Bayesian net, nothing guarantees this product already sums to 1 — that is what Z fixesover all cliques

The ϕ\phi for the you-and-coworker clique might look like this (state 11 = healthy, 00 = sick):

A clique potential φ(h_y, h_c) — affinities, not probabilities. Click a cell for why that state is more or less likely.
joint stateφ (affinity)
both healthy (h_y=1, h_c=1)h_y = 1, h_c = 110
both sick (h_y=0, h_c=0)h_y = 0, h_c = 02
only you sick (h_y=0, h_c=1)h_y = 0, h_c = 11
only coworker sick (h_y=1, h_c=0)h_y = 1, h_c = 01
Dotted-underlined cells have explanations — click one.

Reading the factorization off a graph is just a matter of listing its cliques. Click through the classic six-node example — every node lights up the factors it belongs to:

Fig 16.4 — reading factorization from an undirected graph. The pairwise cliques give p(a,…,f) = (1/Z)·φ_{a,b}φ_{b,c}φ_{a,d}φ_{b,e}φ_{e,f}.
abcdef
1Z\tfrac{1}{Z}ϕa,b\phi_{a,b}ϕb,c\phi_{b,c}ϕa,d\phi_{a,d}ϕb,e\phi_{b,e}ϕe,f\phi_{e,f}

click a node to see which factors mention it

§16.2.3 The partition function

The product of clique potentials is non-negative but need not sum to 11. To get a valid distribution we divide by the partition function ZZ:

Normalizing an undirected model (eqs 16.4–16.5)

p(x)=1Zp~(x),Z=p~(x)dxp(\boldsymbol{x}) = \frac{1}{Z}\,\tilde{p}(\boldsymbol{x}), \qquad Z = \int \tilde{p}(\boldsymbol{x})\, d\boldsymbol{x}
ZZthe partition function: the sum (discrete) or integral (continuous) of p̃ over EVERY joint state — the constant that makes p integrate to 1scalar
1Zp~(x)\frac{1}{Z}\tilde{p}(\boldsymbol{x})the normalized, valid distribution — a Gibbs distributionsums/integrates to 1
dx\int \cdots d\boldsymbol{x}sum over all kⁿ discrete states, or integral over the continuous domain — usually INTRACTABLE, which is why chapter 18 existsover the whole domain

Normalizing a product of clique potentials this way yields what is called a Gibbs distribution . Because ZZ sums over every joint assignment of x\boldsymbol{x}, it is generally intractable in deep learning — confronting it is the entire subject of chapter 18.

Worked example — when Z does not even exist

Take a single scalar xRx \in \mathbb{R} with clique potential ϕ(x)=x2\phi(x) = x^2. Then Z=x2dx=Z = \int_{-\infty}^{\infty} x^2\, dx = \infty: the integral diverges, so no probability distribution corresponds to this ϕ\phi. Choosing ϕ(x;β)=exp(βx2)\phi(x;\beta) = \exp(-\beta x^2) instead, ZZ is finite only for β>0\beta > 0 (giving a Gaussian); every other β\beta makes ϕ\phi impossible to normalize. With undirected models you are not guaranteed a valid distribution for free — you must check that ZZ exists.

This is the deep difference from directed models, which are built out of probability distributions from the start. Undirected models are defined loosely by ϕ\phi functions and normalized afterward, so the domain of the variables dramatically changes what a given set of ϕ\phi‘s even means. Take the single factor ϕ(xi)=exp(bixi)\phi(x_i) = \exp(b_i x_i) and switch its domain:

One clique potential φ(xᵢ)=exp(bᵢxᵢ), three domains. Over ℝ the partition function diverges (no distribution); over {0,1}ⁿ it factorizes into independent sigmoids; over one-hot basis vectors it becomes a softmax where the biases compete. Same φ — the domain decides everything.
p(x₁=1)σ(0.80) = 0.690p(x₂=1)σ(0.20) = 0.550p(x₃=1)σ(-0.50) = 0.378
Each xᵢ is independent: p(x) factorizes into n separate Bernoullis, p(xᵢ=1) = σ(bᵢ). Raising one bias moves only its own bar.
φ(xᵢ) = exp(bᵢ·xᵢ)

One set of factors, three domains, three completely different objects — the lesson of the partition function: with undirected models you must know the variables' domain before a set of φ's even means anything.

Directed vs undirected, in one line

A directed model is a product of conditional probabilities — valid by construction, normalized locally. An undirected model is a product of affinities — valid only after the global division by ZZ, which may be intractable or nonexistent. Directed models make sampling easy; undirected models make it easy to express symmetric, cyclic interactions. Next we meet the most convenient way to guarantee p~>0\tilde{p} > 0energy-based models — and how to read (in)dependence off a graph.

Check yourself — directed, undirected & the partition function

1.In a directed model, what does the arrow a → b assert?

2.A full joint table over n discrete variables with k values costs O(kⁿ). What does a directed model cost, and when does it help?

3.How does a clique potential φ(C) in an undirected model differ from a conditional probability in a directed model?

4.Why can computing the partition function Z be impossible even in principle?

5.Predict the outcome — in PartitionDomainLab you keep φ(xᵢ)=exp(bᵢxᵢ) fixed and switch the domain from {0,1}ⁿ to the one-hot basis. What changes?

5 questions