Approximate Inference: Mean Field Methodsepxing/Class/10708-07/Slides/lecture17... ·...

18
1 1 School of Computer Science Approximate Inference: Mean Field Methods Probabilistic Graphical Models (10 Probabilistic Graphical Models (10- 708) 708) Lecture 17, Nov 12, 2007 Eric Xing Eric Xing X1 X2 X3 X4 X5 X6 X7 X8 Receptor A Kinase C TF F Gene G Gene H Kinase E Kinase D Receptor B X1 X2 X3 X4 X5 X6 X7 X8 X1 X2 X3 X4 X5 X6 X7 X8 Reading: KF-Chap. 12 Eric Xing 2 Questions???? Kalman Filters Complex models LBP-Bethe Minimization

Transcript of Approximate Inference: Mean Field Methodsepxing/Class/10708-07/Slides/lecture17... ·...

Page 1: Approximate Inference: Mean Field Methodsepxing/Class/10708-07/Slides/lecture17... · 2007-11-12 · 1 1 School of Computer Science Approximate Inference: Mean Field Methods Probabilistic

1

1

School of Computer Science

Approximate Inference:Mean Field Methods

Probabilistic Graphical Models (10Probabilistic Graphical Models (10--708)708)

Lecture 17, Nov 12, 2007

Eric XingEric XingReceptor A

Kinase C

TF F

Gene G Gene H

Kinase EKinase D

Receptor BX1 X2

X3 X4 X5

X6

X7 X8

Receptor A

Kinase C

TF F

Gene G Gene H

Kinase EKinase D

Receptor BX1 X2

X3 X4 X5

X6

X7 X8

X1 X2

X3 X4 X5

X6

X7 X8

Reading: KF-Chap. 12

Eric Xing 2

Questions????

Kalman Filters

Complex models

LBP-Bethe Minimization

Page 2: Approximate Inference: Mean Field Methodsepxing/Class/10708-07/Slides/lecture17... · 2007-11-12 · 1 1 School of Computer Science Approximate Inference: Mean Field Methods Probabilistic

2

Eric Xing 3

Approximate Inference

Eric Xing 4

For a distribution p(X|θ) associated with a complex graph, computing the marginal (or conditional) probability of arbitraryrandom variable(s) is intractable

Variational methodsformulating probabilistic inference as an optimization problem:

{ })( maxarg* fFff S∈

=

queries ticprobabiliscertain tosolutions or,ondistributiy probabilit )(tractable a

:f

e.g.

Variational Methods

Page 3: Approximate Inference: Mean Field Methodsepxing/Class/10708-07/Slides/lecture17... · 2007-11-12 · 1 1 School of Computer Science Approximate Inference: Mean Field Methods Probabilistic

3

Eric Xing 5

Exponential representation of graphical models:

Includes discrete models, Gaussian, Poisson, exponential, and many others

⎭⎬⎫

⎩⎨⎧

−= ∑α

αα αφθ )()(exp)|( θθ Ap DXX

−= ∑ xXXα

αα αφθ )()( state of theas toreferred is energyE D

{ })()(exp)|( θθ AEp −−= XX

{ })(),(exp EEH AE xxX θ,−−=

Exponential Family

∏∈

=Cc

ccZP )()( XX ψ1

Eric Xing 6

⎭⎬⎫

⎩⎨⎧

+= ∑∑< i

iiji

jiij XXXZ

Xp 0exp1)( θθ

Example: the Boltzmanndistribution on atomic lattice

Page 4: Approximate Inference: Mean Field Methodsepxing/Class/10708-07/Slides/lecture17... · 2007-11-12 · 1 1 School of Computer Science Approximate Inference: Mean Field Methods Probabilistic

4

Eric Xing 7

4

8

-2 -1 0 1 2

))(exp()exp( 1+−≥ µµ xx )exp(x( ))()()()exp()exp( 163

61 23 +−+−+−≥ µµµµ xxxx )exp(x

Lower bounds of exponential functions

Eric Xing 8

Lemma: Every marginal distribution q(XH) defines a lower bound of likelihood:

where xE denotes observed variables (evidence).

{ }( )( ) , )(),()(

)(exp)(

HEHE

HHE

EEA

Edp

xxxx

xxx

′−−−

′−≥ ∫1

Upgradeable to higher order bound Upgradeable to higher order bound [Leisink and Kappen, 2000]

Representing q(XH) by exp{-E’(XH)}:

Lower bounding likelihood

Page 5: Approximate Inference: Mean Field Methodsepxing/Class/10708-07/Slides/lecture17... · 2007-11-12 · 1 1 School of Computer Science Approximate Inference: Mean Field Methods Probabilistic

5

Eric Xing 9

Lemma: Every marginal distribution q(XH) defines a lower bound of likelihood:

where xE denotes observed variables (evidence).

,

)(log)(),()()(

qq

HHHqEHE

HEC

qqdECpH

+−=

−−≥ ∫ xxxxXxX

Representing q(XH) by exp{-E’(XH)}:

,qqHEC +−=

entropy :

energy expected :

q

q

H

E energy free Gibbs : qqHE −

Lower bounding likelihood

Eric Xing 10

Kullback-Leibler Distance:

“Boltzmann’s Law” (definition of “energy”):

∑≡z zp

zqzqpqKL)()(ln)()||(

KL and variational (Gibbs) free energy

[ ])(exp)( zEC

zp −=1

∑ ∑ ++≡z z

CzqzqzEzqpqKL ln)(ln)()()()||(

Gibbs Free Energy ; minimized when )()( ZpZq =

)(qG

Page 6: Approximate Inference: Mean Field Methodsepxing/Class/10708-07/Slides/lecture17... · 2007-11-12 · 1 1 School of Computer Science Approximate Inference: Mean Field Methods Probabilistic

6

Eric Xing 11

KL and Log LikelihoodJensen’s inequality

KL and Lower bound of likelihood

Setting q()=p(z|x) closes the gap (c.f. EM)

=

=

=

z

z

z

xzqzxpxzq

xzqzxpxzq

zxpxpx

)|()|,(log)|(

)|()|,()|(log

)|,(log)|(log);(

θ

θ

θθθl

)(),;();( qHzxx qqc Lll =+≥⇒ θθ

∑∑

+=

=

===

zz

z

z

xzpzqzq

zqzxpzq

xzpzq

zqzxpzq

xzpzxpzq

xzpzxpxpx

),|()(log)(

)()|,(log)(

),|()(

)()|,(log)(

),|()|,(log)(

),|()|,(log)|(log);(

θθ

θθ

θθ

θθθθl

)||()();( pqKLqx +=⇒ Ll θ

ln ( )p Dln ( )p D

L( )qL( )q

KL( || )q pKL( || )q p

Eric Xing 12

{ }

{ }qqQq

qqQq

HE

HEq

−=

+−=

minarg

maxarg

Difficulty: Hq is intractable for general q

“solution”: approximate Hqand/or, relax or tighten Q

where Q is the equivalent sets of realizable distributions, e.g., all valid parameterizations of exponential family distributions, marginal polytopes[winright et al. 2003].

A variational representation of probability distributions

Page 7: Approximate Inference: Mean Field Methodsepxing/Class/10708-07/Slides/lecture17... · 2007-11-12 · 1 1 School of Computer Science Approximate Inference: Mean Field Methods Probabilistic

7

Eric Xing 13

But we do not optimize q(X) explicitly, focus on the set of beliefs

e.g.,

Relax the optimization problem

approximate objective:relaxed feasible set:

The loopy BP algorithm: a fixed point iteration procedure that tries to solve b*

{ })( minarg* bFEbbb o

−=∈M

)}( ),,({ , iijiji xbxxbb ττ ===

)(bFHq ≈

oMM → )( MM ⊇o

) ,( , ijiBetha bbHH =

{ }∑∑ ==≥=ii x

jjix

io xxxx )(),(,)(| ττττ 10M

Bethe Free Energy/LBP

Eric Xing 14

Optimize q(XH) in the space of tractable families

i.e., subgraph of Gp over which exact computation of Hq is feasible

Tightening the optimization space

exact objective:tightened feasible set:

qHTQ →

qqqHEq −=

∈ minarg*

T

)( QT ⊆

Mean field methods

Page 8: Approximate Inference: Mean Field Methodsepxing/Class/10708-07/Slides/lecture17... · 2007-11-12 · 1 1 School of Computer Science Approximate Inference: Mean Field Methods Probabilistic

8

Eric Xing 15

Mean Field ApproximationMean Field Approximation

Eric Xing 16

)]([ XpG

)}]([{ cc XqG

Exact:

Clusters:

(intractable)

Cluster-based approx. to the Gibbs free energy (Wiegerinck 2001,

Xing et al 03,04)

Page 9: Approximate Inference: Mean Field Methodsepxing/Class/10708-07/Slides/lecture17... · 2007-11-12 · 1 1 School of Computer Science Approximate Inference: Mean Field Methods Probabilistic

9

Eric Xing 17

Mean field approx. to Gibbs free energy

Given a disjoint clustering, {C1, … , CI}, of all variablesLet

Mean-field free energy

Will never equal to the exact Gibbs free energy no matter what clustering is used, but it does always define a lower bound of the likelihood

Optimize each qi(xc)'s. Variational calculus …Do inference in each qi(xc) using any tractable algorithm

),()( ii

iqq CXX ∏=

( ) ( ) ( )∑∑∑∑∏ +=i

CiCii

Ci

CiiC

iii

iC

iqqEqG

xxxxxx ln)(MF

( ) ( ) ( ) ( ) ( )∑∑∑∑∑∑ ++=< i x

iii

ix

iji

jixx

jiiiji

xqxqxxqxxxqxqG ln)()( e.g., MF φφ (naïve mean field)

Eric Xing 18

),|()( ,,,,*

ijiiii qMBHCECHCHi pq

= XxXX

Theorem: The optimum GMF approximation to the cluster marginal is isomorphic to the cluster posterior of the original distribution given internal evidence and its generalized mean fields:

GMF algorithm: Iterate over each qi

The Generalized Mean Field theorem

Page 10: Approximate Inference: Mean Field Methodsepxing/Class/10708-07/Slides/lecture17... · 2007-11-12 · 1 1 School of Computer Science Approximate Inference: Mean Field Methods Probabilistic

10

Eric Xing 19

[xing et al. UAI 2003]

A generalized mean field algorithm

Eric Xing 20

[xing et al. UAI 2003]

A generalized mean field algorithm

Page 11: Approximate Inference: Mean Field Methodsepxing/Class/10708-07/Slides/lecture17... · 2007-11-12 · 1 1 School of Computer Science Approximate Inference: Mean Field Methods Probabilistic

11

Eric Xing 21

Theorem: The GMF algorithm is guaranteed to converge to a local optimum, and provides a lower bound for the likelihood of evidence (or partition function) the model.

Convergence theorem

Eric Xing 22

Gibbs predictive distribution:

⎪⎭

⎪⎬⎫

⎪⎩

⎪⎨⎧

++= ∑∈

−ij

ijiijiiii AxXXxXpN

θθ 0exp)|(

}):{|( iji jxXp N∈=

jx

jx

mean field equation:

}):{|(

exp)(

iji

jiqjiijiiii

jXXp

AXXXXq

jq

ij

NN

∈⟩⟨=

⎪⎭

⎪⎬⎫

⎪⎩

⎪⎨⎧

++= ∑∈

θθ 0jq

jX

}:{ ij jXjq

N∈⟩⟨

Xi

Approximate p(X) by fully factorized q(X)=Piqi(Xi)

For Boltzmann distribution p(X)=exp{∑i < j qijXiXj+qioXi}/Z :

Xi

ℑxj⟩qj resembles a “message” sent from node j to i

{⟨xj⟩qj : j ∈ Ni} forms the “mean field” applied to Xi from its neighborhood}:{ iqj jXj

N∈⟩⟨jqjX

The naive mean field approximation

Page 12: Approximate Inference: Mean Field Methodsepxing/Class/10708-07/Slides/lecture17... · 2007-11-12 · 1 1 School of Computer Science Approximate Inference: Mean Field Methods Probabilistic

12

Eric Xing 23

Cluster marginal of a square block Ck:

⎪⎭

⎪⎬

⎪⎩

⎪⎨

⎧++∝ ∑ ∑∑

∈ ∈∈

∈∈kkMBCk

kMBjkCi kCk

kCji

XqjiijCi

iijiijC XXXXXXq,

)(

',, '

exp)( θθθ 0

Virtually a reparameterized Ising model of small size.

Generalized MF approximation to Ising models

Eric Xing 24

GMF approximation to Isingmodels

GMF2x2

GMF4x4

BP

Attractive coupling: positively weightedRepulsive coupling: negatively weighted

Page 13: Approximate Inference: Mean Field Methodsepxing/Class/10708-07/Slides/lecture17... · 2007-11-12 · 1 1 School of Computer Science Approximate Inference: Mean Field Methods Probabilistic

13

Eric Xing 25

Automatic Variational Inference

Currently for each new model we have to derive the variational update equations write application-specific code to find the solution

Each can be time consuming and error prone

Can we build a general-purpose inference engine which automates these procedures?

... ... ... ...

A AA Ax2 x3x1 xN

yk2 yk3yk1 ykN...

...

y12 y13y11 y1N...

S2 S3S1 SN...

... ... ... ...

A AA Ax2 x3x1 xN

yk2 yk3yk1 ykN...

...

y12 y13y11 y1N...

S2 S3S1 SN...

fHMM Mean field approx. Structured variational approx.

⇒⇒

Eric Xing 26

a general, iterative message passing algorithm

clustering completely defines approximation

preserves dependencies flexible performance/cost trade-offclustering automatable

recovers model-specific structured VI algorithms, including:

fHMM, LDA variational Bayesian learning algorithms

easily provides new structured VI approximations to complex models

Cluster-based MF (e.g., GMF)

Page 14: Approximate Inference: Mean Field Methodsepxing/Class/10708-07/Slides/lecture17... · 2007-11-12 · 1 1 School of Computer Science Approximate Inference: Mean Field Methods Probabilistic

14

Eric Xing 27

Example 1: Bayesian Gaussian Model

Likelihood function

Conjugate priors

Factorized variational distribution

mean precision (inverse variance)

Eric Xing 28

Variational Posterior Distribution

where

Page 15: Approximate Inference: Mean Field Methodsepxing/Class/10708-07/Slides/lecture17... · 2007-11-12 · 1 1 School of Computer Science Approximate Inference: Mean Field Methods Probabilistic

15

Eric Xing 29

Initial Configuration

−1 0 10

1

2

µ

τ

(a)

Eric Xing 30

After Updating q(µ)

−1 0 10

1

2

µ

τ

(b)

Page 16: Approximate Inference: Mean Field Methodsepxing/Class/10708-07/Slides/lecture17... · 2007-11-12 · 1 1 School of Computer Science Approximate Inference: Mean Field Methods Probabilistic

16

Eric Xing 31

After Updating q(µ)

−1 0 10

1

2

µ

τ

(c)

Eric Xing 32

Converged Solution

−1 0 10

1

2

µ

τ

(d)

Page 17: Approximate Inference: Mean Field Methodsepxing/Class/10708-07/Slides/lecture17... · 2007-11-12 · 1 1 School of Computer Science Approximate Inference: Mean Field Methods Probabilistic

17

Eric Xing 33

Example 2: Latent Dirichlet Allocation

Blei, Jordan and Ng (2003)Generative model of documents (but broadly applicable e.g. collaborative filtering, image retrieval, bioinformatics)Generative model:

choosechoose topicchoose word

NM

wz

Eric Xing 34

Latent Dirichlet AllocationVariational approximation

Data set:15,000 documents 90,000 terms2.1 million words

Model:100 factors9 million parameters

MCMC could be totally infeasible for this problem

⇒( )( ))ln,(|Multi

),(|Dir)()(),(

θβφ

αγθθθ θ

w

z

fzzf

zqqzq

=

×==

=

Page 18: Approximate Inference: Mean Field Methodsepxing/Class/10708-07/Slides/lecture17... · 2007-11-12 · 1 1 School of Computer Science Approximate Inference: Mean Field Methods Probabilistic

18

Eric Xing 35

GMFr

GMFb

BP

Example 3: Sigmoid belief network

Eric Xing 36

Example 4: Factorial HMM