1 of 72

PATTERN RECOGNITION �AND MACHINE LEARNING

CHAPTER 8: GRAPHICAL MODELS

2 of 72

Bayesian Networks

Directed Acyclic Graph (DAG)

3 of 72

Bayesian Networks

General Factorization

4 of 72

Bayesian Curve Fitting (1)

Polynomial

5 of 72

Bayesian Curve Fitting (2)

Plate

6 of 72

Bayesian Curve Fitting (3)

Input variables and explicit hyperparameters

7 of 72

Bayesian Curve Fitting —Learning

Condition on data

8 of 72

Bayesian Curve Fitting —Prediction

Predictive distribution:

where

9 of 72

Generative Models

Causal process for generating images

10 of 72

Discrete Variables (1)

General joint distribution: K 2 { 1 parameters

​

​

​

Independent joint distribution: 2(K { 1) parameters

​

11 of 72

Discrete Variables (2)

General joint distribution over M variables: �KM { 1 parameters

​

M -node Markov chain: K { 1 + (M { 1) K(K { 1) parameters

12 of 72

Discrete Variables: Bayesian Parameters (1)

13 of 72

Discrete Variables: Bayesian Parameters (2)

Shared prior

14 of 72

Parameterized Conditional Distributions

If are discrete,

K-state variables,

in general has O(K M) parameters.

The parameterized form

​

​

​

requires only M + 1 parameters

15 of 72

Linear-Gaussian Models

Directed Graph

​

​

​

​

Vector-valued Gaussian Nodes

Each node is Gaussian, the mean is a linear function of the parents.

​

16 of 72

Conditional Independence

a is independent of b given c

​

​

Equivalently

​

​

Notation

17 of 72

Conditional Independence: Example 1

18 of 72

Conditional Independence: Example 1

19 of 72

Conditional Independence: Example 2

20 of 72

Conditional Independence: Example 2

21 of 72

Conditional Independence: Example 3

​

​

​

​

​

​

​

​

​

​

​

Note: this is the opposite of Example 1, with c unobserved.

22 of 72

Conditional Independence: Example 3

​

​

​

​

​

​

​

​

​

​

​

Note: this is the opposite of Example 1, with c observed.

23 of 72

“Am I out of fuel?”

B = Battery (0=flat, 1=fully charged)

F = Fuel Tank (0=empty, 1=full)

G = Fuel Gauge Reading� (0=empty, 1=full)

and hence

24 of 72

“Am I out of fuel?”

Probability of an empty tank increased by observing G = 0.

25 of 72

“Am I out of fuel?”

Probability of an empty tank reduced by observing B = 0.

This referred to as “explaining away”.

26 of 72

D-separation

  • A, B, and C are non-intersecting subsets of nodes in a directed graph.
  • A path from A to B is blocked if it contains a node such that either
    1. the arrows on the path meet either head-to-tail or tail-to-tail at the node, and the node is in the set C, or
    2. the arrows meet head-to-head at the node, and neither the node, nor any of its descendants, are in the set C.
  • If all paths from A to B are blocked, A is said to be d-separated from B by C.
  • If A is d-separated from B by C, the joint distribution over all variables in the graph satisfies .

27 of 72

D-separation: Example

28 of 72

D-separation: I.I.D. Data

29 of 72

Directed Graphs as Distribution Filters

30 of 72

The Markov Blanket

Factors independent of xi cancel between numerator and denominator.

31 of 72

Markov Random Fields

Markov Blanket

32 of 72

Cliques and Maximal Cliques

Clique

Maximal Clique

Hammersley-Clifford theorem

1990

33 of 72

Joint Distribution

​

​

where is the potential over clique C and

​

​

​

is the normalization coefficient; note: M K-state variables → KM terms in Z.

​

​

Energies and the Boltzmann distribution

potential function is defined strictly positive

one of major limitation of undirected graph

34 of 72

Illustration: Image De-Noising (1)

Original Image

Noisy Image

35 of 72

Illustration: Image De-Noising (2)

Min

Max

x, y = {1, -1}

unknown original image

known noisy image

0

1.0

2.1

h can bias the model towards pixel values that have one particular sign in

preference to the other.

​

36 of 72

Illustration: Image De-Noising (3)

Noisy Image

Restored Image (ICM)

local optimum

37 of 72

Illustration: Image De-Noising (4)

Restored Image (Graph cuts)

Restored Image (ICM)

global optimum

38 of 72

Converting Directed to Undirected Graphs (1)

39 of 72

Converting Directed to Undirected Graphs (2)

Additional links

moralization

40 of 72

Directed vs. Undirected Graphs (1)

41 of 72

Directed vs. Undirected Graphs (2)

D-Map

I-Map

Distribution Independent Property

perfect Map

42 of 72

Inference in Graphical Models

MAP (maximum a posterior estimate)

marginal

Bayes' theorem

joint distribution

sum-product algorithm

max-sum algorithm

max-sum algorithm

43 of 72

Inference on a Chain

marginal

joint distribution

44 of 72

Inference on a Chain

45 of 72

Inference on a Chain

recursive notation

46 of 72

Inference on a Chain

message passing of Markov Chains

P43. summation of p(x1) to p(xn)

47 of 72

Inference on a Chain

To compute local marginals:

    • Compute and store all forward messages, .
    • Compute and store all backward messages, .
    • Compute Z at any node xm
    • Compute���for all variables required.

​

efficiently in time that is linear in the number of nodes

48 of 72

Trees

Undirected Tree

Directed Tree

Polytree

directed graph with

  1. more than one parent
  2. only one path

message passing for chains is called sum-product algorithm, which provides an efficient framework for exact inference in tree-structured graphs (not cycle)

directed polytree, conversion to an undirected graph results in loops

due to the moralization step, whereas conversion to a factor graph again results in a tree. Factor graph can keep tree-still conversion.

49 of 72

Factor Graphs (bipartite)

sum-product algorithm can be cast in a particularly simple

and general form if we first introduce a new graphical construction called a factor

graph (Frey, 1998; Kschischnang et al., 2001).

, Xs denotes a subset of the variables

50 of 72

Factor Graphs from Directed Graphs

fs(xs) are local conditional distributions

51 of 72

Factor Graphs from Undirected Graphs

local cycles in a directed/undirected graph due to links connecting parents of a node can be removed on conversion to a factor graph

by defining the appropriate factor function

1. create variable nodes corresponding to the nodes in the original undirected graph

2. create additional factor nodes corresponding to the maximal cliques xs

​

​

52 of 72

The Sum-Product Algorithm (1)

Objective:

    • to obtain an efficient, exact inference algorithm for finding marginals; O(n)
    • in situations where several marginals are required, to allow computations to be shared efficiently. (calculate one marginal can be reused its path)

Key idea: Distributive Law

ref p44, p56

unrelated variable can be move outside this summation

53 of 72

The Sum-Product Algorithm (2)

marginal distribution (Sum)

Distribution (Product)

ref p42

Xs denotes the set of all variables in the subtree connected to the variable node x via the factor node

F(x, Xs) presents the product of all the factors in the group associated with factor fs.

​

​

所有聯集fs相乘,就是distribution. p49

所有不屬於x的變數,可切分成跟fs關聯

整體clique連乘,可切分為neighbor clique連乘

54 of 72

The Sum-Product Algorithm (3)

交換product和sum

55 of 72

The Sum-Product Algorithm (4)

56 of 72

The Sum-Product Algorithm (5)

57 of 72

The Sum-Product Algorithm (6)

58 of 72

The Sum-Product Algorithm (7)

Initialization

59 of 72

The Sum-Product Algorithm (8)

To compute local marginals:

    • Pick an arbitrary node as root
    • Compute and propagate messages from the leaf nodes to the root, storing received messages at every node.
    • Compute and propagate messages from the root to the leaf nodes, storing received messages at every node.
    • Compute the product of received messages at each node for which the marginal is required, and normalize if necessary. (only in undirected graph)

backward propagation because need calculating marginal for each node p(xi), max-sum algorithm need not

60 of 72

Sum-Product: Example (1)

unnormalized cliques

61 of 72

Sum-Product: Example (2)

62 of 72

Sum-Product: Example (3)

63 of 72

Sum-Product: Example (4)

64 of 72

The Max-Sum Algorithm (1)

Objective: an efficient algorithm for finding

    • the value xmax that maximises p(x);
    • the value of p(xmax).

​

In general, maximum marginals ≠ joint maximum.

joint maximum

65 of 72

The Max-Sum Algorithm (2)

Maximizing over a chain (max-product)

​

​

​

Max neighbor clique from leaf node and propagate

66 of 72

The Max-Sum Algorithm (3)

Generalizes to tree-structured factor graph

​

​

maximizing as close to the leaf nodes as possible

67 of 72

The Max-Sum Algorithm (4)

Max-Product → Max-Sum

For numerical reasons, use

​

​

Again, use distributive law

​

ref p67

unrelated variable can be move outside this summation

68 of 72

The Max-Sum Algorithm (5)

Initialization (leaf nodes)

​

Recursion

​

​

​

ref p65

69 of 72

The Max-Sum Algorithm (6)

Termination (root node)

​

​

​

Back-track, for all nodes i with l factor nodes to the root (l=0)

​

​

​

70 of 72

The Max-Sum Algorithm (7)

Example: Markov chain

​

From node n backtrack to all leaves with multiple path

71 of 72

The Junction Tree Algorithm

  • Exact inference on general graphs.
  • Works by turning the initial graph into a junction tree and then running a sum-product-like algorithm.
  • Intractable on graphs with large cliques.

Not tree graph with loop

72 of 72

Loopy Belief Propagation

  • Sum-Product on general graphs.
  • Initial unit messages passed across all links, after which messages are passed around until convergence (not guaranteed!).
  • Approximate but tractable for large graphs.
  • Sometime works well, sometimes not at all.

Not tree graph with loop