492 words
2 minutes
[CS5340] Factor Graph & Junction Tree Algorithm

Factor Graph#

factor graph

  • to explicitedly show details of factorization
  • Variable + Factor nodes
  • G(V,F,ϵ)G(V, F, \epsilon)
    • VV: random variable (circle)
    • FF: factors (square)
    • ϵ\epsilon: undirected edges, factor to all variable it depends on
  • p(x)=sfs(xs)p(x) = \prod_s f_s(x_s)

DGM to factor graph:#

  • parent-child relationship p(xixπi)fs(xs)p(x_i|x_{\pi_i}) \rightarrow f_s(x_s)

UGM to factor graph:#

  • 1Z(θ)c𝜓c(ycθc)\frac {1}{Z(\theta)} \prod_c 𝜓_c(y_c| \theta_c)
    • maximum clique 𝜓cfs(xs)𝜓_c \rightarrow f_s(x_s)
    • can remove 1Z(θ)\frac {1}{Z(\theta)} since can define it over empty set of variables
NOTE

factor graph representation is not unique

  • DGM / UGM with local cycles can become tree
    • therefore can run sum-product algorithm example

Sum-Product algorithm on factor graph#

  • Goal: compute all singleton marginal probability p(xi)p(x_i)
  • Message:
    • vv: variable to factor node
      • Vis(xi)=tN(i)sμti(xi)V_{is}(x_i) = \prod_{t \in N(i)-s} \mu_{ti{ (x_i)}}
      • no marginalization message example 1
    • μ\mu: factor to variable node
      • μsi(xi)=xN(s)ifs(xN(s))jN(s)ivjs(xj)\mu_{si}(x_i) = \sum_{x_{N(s)-i}} f_s(x_{N(s)}) \prod_{j \in N(s)-i} v_{js}(x_j)
      • should contain only xix_i, marginaliza away all other nodes message example 2
    • message from leaf node (Initialization)
      • vis(xi)=1v_{is}(x_i)=1
      • μsi(xi)=fs(xs)\mu_{si}(x_i) = f_s(x_s)
  • Marginal probability
    • p(xi)sN(i)μsi(xi)=Vis(xi)μsi(xi)p(x_i) \propto \prod_{s \in N(i)} \mu_{si}(x_i) = V_{is}(x_i)\mu_{si}(x_i) marginal probability

Maximum a Posterior (MAP) problem#

  • Goal: to maximize over all sets of random variables
    • find the maximal probability
    • find the configuration
  • maxxp(xxˉE)=maxxp(x,xˉE)p(xˉE)max_x p(x|\bar x_E) = max_x \frac {p(x, \bar x_E)}{p(\bar x_E)} (p(xˉE)p(\bar x_E) can be removed)
    =maxxp(xxˉE)=maxxp(x)δ(xE,xˉE)=maxxp(x)E= max_x p(x|\bar x_E) = max_x p(x) \delta(x_E, \bar x_E) \\ = max_x p(x)^E
CAUTION

Underflow problem: prodects of 0.x00.x \rightarrow 0

  • Solution: log scale, maxxp(x)E=maxxlogp(x)Emax_x p(x)^E = max_x log p(x)^E
    ×+\times \Rightarrow + (becomes Max-Sum algorithm)

Max-Product Algorithm#

Or Max-Sum algorithm if using log scale

  • similar to Sum-Product algorithm
  • inward message
    • mjimax(xi)=maxxj(𝜓E(xj)𝜓(xi,xj)kN(j)imkjmax(xj))m_{ji}^{max}(x_i) = max_{x_j}(𝜓^E(x_j)𝜓(x_i,x_j) \prod_{k \in {N(j)-i}} m_{kj}^{max}(x_j)) inward message
  • maxxpE(x)=maxxi(𝜓E(xf)wN(f)mefmax(xf))max_x p^E(x) = max_{x_i} (𝜓^E(x_f) \prod_{w \in N(f)} m_{ef}^{max} (x_f))

Getting the configurations#

  • also record max configuration per inward message
  • track the configurations from root as outward process
  • Trellis diagram Trellis diagram

Junction Tree (Clique Tree)#

  • Probability distributions of a loopy undirected graph can be re-parameterizes as trees \Rightarrow can perform Sum-Product algorithm
  • Cluster graph no cycle\overset{no\ cycle}{\rightarrow} Cluster tree running intersection property\overset{running\ intersection\ property}{\rightarrow} Junction tree
    • Cluster graph
      • cluster nodes Ci{x1,...xn}C_i \subset \{ x_1, ... x_n\} edges between Ci,Cj C_i, C_j\ \Rightarrow sepset (intersection) Sij=CiCjS_{ij} = C_i \cap C_j
    • Family preservation: each potential 𝜓k𝜓_k is assigned to a cluster Cα(k)C_{\alpha (k)} such that Scope[𝜓k]Cα(k)Scope[𝜓_k] \subset C_{\alpha (k)}
    • Cluster potential: ϕj(Cj)=𝜓:α(𝜓)=j𝜓\phi_j (C_j) = \prod_{𝜓: \alpha(𝜓)=j}𝜓
      • ensure each 𝜓𝜓 is used once and only once
  • Running intersection property
    • for each pair of clusters Ci,CjC_i, C_j and XCiCjX \in C_i \cap C_j, there exists an unique path between Ci,CjC_i, C_j fpr which all clusters and sepset contain XX
    • a.k.a for any XX, the set of clusters & sepsets containing XX form a tree.
    • If fulfilled by cluster tree, it is a junction tree

what can junstion tree do?

  • Marginal probability on junction tree
    1. choose root clique
    2. inward message
    3. outward message
    • messages: δij=CiSijϕikN(x)jδki\delta_{i \rightarrow j} = \sum_{C_i - S_{ij}} \phi_i \prod_{k \in N(x)-j} \delta_{k \rightarrow i}
      • CiSijC_i - S_{ij}: random variable that are in CiC_i but not in CjC_j, need to marginalize out
      • SijS_{ij}: common random variables in both CiC_i & CjC_j
    • p(Ci)ϕikN(i)δkip(C_i) \propto \phi_i \prod_{k \in N(i)} \delta_{k \rightarrow i}

Constructing Junction tree#

  1. Triangulation: get reconstitution graph

    • DAG to UAG to reconstitution graph step 1
  2. Get all clusters and all possible sepsets step 2

  3. Assign cluster potentials step 3

  4. Get junction tree

    • find the maximum spanning tree with weight == cardinality of sepsets
    TIP

    A cluster tree is a junction tree only if it is a maximum spanning tree

    junction tree

[CS5340] Factor Graph & Junction Tree Algorithm
https://itsjeremyhsieh.github.io/posts/cs5340-5-factor-graph-and-junction-tree-algorithm/
Author
Jeremy H
Published at
2024-09-09