Probabilistic Inference Lecture 2 M. Pawan Kumar Slides available online
Pose Estimation Courtesy Pedro Felzenszwalb
Pose Estimation Courtesy Pedro Felzenszwalb
Pose Estimation Variables are body partsLabels are positions
Pose Estimation Unary potentials θ a;i proportional to fraction of foreground pixels Variables are body partsLabels are positions
Pose Estimation Pairwise potentials θ ab;ik proportional to d 2 Head Torso Joint location according to ‘head’ part Joint location according to ‘torso’ part d
Pose Estimation Pairwise potentials θ ab;ik proportional to d 2 Head Torso d Head Torso d >
Outline Problem Formulation –Energy Function –Energy Minimization –Computing min-marginals Reparameterization Energy Minimization for Trees Loopy Belief Propagation
Energy Function VaVa VbVb VcVc VdVd Label l 0 Label l 1 Random Variables V = {V a, V b, ….} Labels L = {l 0, l 1, ….} Labelling f: {a, b, …. } {0,1, …}
Energy Function VaVa VbVb VcVc VdVd Q(f) = ∑ a a;f(a) Unary Potential Label l 0 Label l 1 Easy to minimize Neighbourhood
Energy Function VaVa VbVb VcVc VdVd E : (a,b) E iff V a and V b are neighbours E = { (a,b), (b,c), (c,d) } Label l 0 Label l 1
Energy Function VaVa VbVb VcVc VdVd +∑ (a,b) ab;f(a)f(b) Pairwise Potential Label l 0 Label l 1 Q(f) = ∑ a a;f(a)
Energy Function VaVa VbVb VcVc VdVd Parameter Label l 0 Label l 1 +∑ (a,b) ab;f(a)f(b) Q(f; )= ∑ a a;f(a)
Outline Problem Formulation –Energy Function –Energy Minimization –Computing min-marginals Reparameterization Energy Minimization for Trees Loopy Belief Propagation
Energy Minimization VaVa VbVb VcVc VdVd Q(f; ) = ∑ a a;f(a) + ∑ (a,b) ab;f(a)f(b) Label l 0 Label l 1
Energy Minimization VaVa VbVb VcVc VdVd Q(f; ) = ∑ a a;f(a) + ∑ (a,b) ab;f(a)f(b) = 13 Label l 0 Label l 1
Energy Minimization VaVa VbVb VcVc VdVd Q(f; ) = ∑ a a;f(a) + ∑ (a,b) ab;f(a)f(b) Label l 0 Label l 1
Energy Minimization VaVa VbVb VcVc VdVd Q(f; ) = ∑ a a;f(a) + ∑ (a,b) ab;f(a)f(b) = 27 Label l 0 Label l 1
Energy Minimization VaVa VbVb VcVc VdVd Q(f; ) = ∑ a a;f(a) + ∑ (a,b) ab;f(a)f(b) f* = arg min Q(f; ) q* = min Q(f; ) = Q(f*; ) Label l 0 Label l 1
Energy Minimization f(a)f(b)f(c)f(d) Q(f; ) possible labellings f(a)f(b)f(c)f(d) Q(f; ) f* = {1, 0, 0, 1} q* = 13
Outline Problem Formulation –Energy Function –Energy Minimization –Computing min-marginals Reparameterization Energy Minimization for Trees Loopy Belief Propagation
Min-Marginals VaVa VbVb VcVc VdVd f* = arg min Q(f; ) such that f(a) = i Min-marginal q a;i Label l 0 Label l 1
Min-Marginals 16 possible labellings q a;0 = 15 f(a)f(b)f(c)f(d) Q(f; ) f(a)f(b)f(c)f(d) Q(f; )
Min-Marginals 16 possible labellings q a;1 = 13 f(a)f(b)f(c)f(d) Q(f; ) f(a)f(b)f(c)f(d) Q(f; )
Min-Marginals and MAP Minimum min-marginal of any variable = energy of MAP labelling min f Q(f; ) such that f(a) = i q a;i min i min i ( ) V a has to take one label min f Q(f; )
Summary Energy Minimization f* = arg min Q(f; ) Q(f; ) = ∑ a a;f(a) + ∑ (a,b) ab;f(a)f(b) Min-marginals q a;i = min Q(f; ) s.t. f(a) = i Energy Function
Outline Problem Formulation Reparameterization Energy Minimization for Trees Loopy Belief Propagation
Reparameterization VaVa VbVb f(a)f(b) Q(f; ) Add a constant to all a;i Subtract that constant from all b;k
Reparameterization f(a)f(b) Q(f; ) Add a constant to all a;i Subtract that constant from all b;k Q(f; ’) = Q(f; ) VaVa VbVb
Reparameterization VaVa VbVb f(a)f(b) Q(f; ) Add a constant to one b;k Subtract that constant from ab;ik for all ‘i’ - 3
Reparameterization VaVa VbVb f(a)f(b) Q(f; ) Q(f; ’) = Q(f; ) Add a constant to one b;k Subtract that constant from ab;ik for all ‘i’
Reparameterization VaVa VbVb VaVa VbVb VaVa VbVb ’ a;i = a;i ’ b;k = b;k ’ ab;ik = ab;ik + M ab;k - M ab;k + M ba;i - M ba;i Q(f; ’) = Q(f; )
Reparameterization Q(f; ’) = Q(f; ), for all f ’ is a reparameterization of , iff ’ ’ b;k = b;k ’ a;i = a;i ’ ab;ik = ab;ik + M ab;k - M ab;k + M ba;i - M ba;i Equivalently Kolmogorov, PAMI, 2006 VaVa VbVb
Recap Energy Minimization f* = arg min Q(f; ) Q(f; ) = ∑ a a;f(a) + ∑ (a,b) ab;f(a)f(b) Min-marginals q a;i = min Q(f; ) s.t. f(a) = i Q(f; ’) = Q(f; ), for all f ’ Reparameterization
Outline Problem Formulation Reparameterization Energy Minimization for Trees Loopy Belief Propagation Pearl, 1988
Belief Propagation Belief Propagation is exact for chains Some problems are easy Exact MAP for trees Clever Reparameterization
Two Variables VaVa VbVb VaVa VbVb Choose the right constant ’ b;k = q b;k Add a constant to one b;k Subtract that constant from ab;ik for all ‘i’
VaVa VbVb VaVa VbVb Choose the right constant ’ b;k = q b;k a;0 + ab;00 = a;1 + ab;10 = min M ab;0 = Two Variables
VaVa VbVb VaVa VbVb Choose the right constant ’ b;k = q b;k Two Variables
VaVa VbVb VaVa VbVb Choose the right constant ’ b;k = q b;k f(a) = 1 ’ b;0 = q b;0 Two Variables Potentials along the red path add up to 0
VaVa VbVb VaVa VbVb Choose the right constant ’ b;k = q b;k a;0 + ab;01 = a;1 + ab;11 = min M ab;1 = Two Variables
VaVa VbVb VaVa VbVb Choose the right constant ’ b;k = q b;k f(a) = 1 ’ b;0 = q b;0 f(a) = 1 ’ b;1 = q b;1 Minimum of min-marginals = MAP estimate Two Variables
VaVa VbVb VaVa VbVb Choose the right constant ’ b;k = q b;k f(a) = 1 ’ b;0 = q b;0 f(a) = 1 ’ b;1 = q b;1 f*(b) = 0f*(a) = 1 Two Variables
VaVa VbVb VaVa VbVb Choose the right constant ’ b;k = q b;k f(a) = 1 ’ b;0 = q b;0 f(a) = 1 ’ b;1 = q b;1 We get all the min-marginals of V b Two Variables
Recap We only need to know two sets of equations General form of Reparameterization ’ a;i = a;i ’ ab;ik = ab;ik + M ab;k - M ab;k + M ba;i - M ba;i ’ b;k = b;k Reparameterization of (a,b) in Belief Propagation M ab;k = min i { a;i + ab;ik } M ba;i = 0
Three Variables VaVa VbVb VcVc Reparameterize the edge (a,b) as before l0l0 l1l1
VaVa VbVb VcVc Reparameterize the edge (a,b) as before f(a) = Three Variables l0l0 l1l1
VaVa VbVb VcVc Reparameterize the edge (a,b) as before f(a) = 1 Potentials along the red path add up to Three Variables l0l0 l1l1
VaVa VbVb VcVc Reparameterize the edge (b,c) as before f(a) = 1 Potentials along the red path add up to Three Variables l0l0 l1l1
VaVa VbVb VcVc Reparameterize the edge (b,c) as before f(a) = 1 Potentials along the red path add up to 0 f(b) = 1 f(b) = Three Variables l0l0 l1l1
VaVa VbVb VcVc Reparameterize the edge (b,c) as before f(a) = 1 Potentials along the red path add up to 0 f(b) = 1 f(b) = 0 q c;0 q c; Three Variables l0l0 l1l1
VaVa VbVb VcVc f(a) = 1 f(b) = 1 f(b) = 0 q c;0 q c;1 f*(c) = 0 f*(b) = 0f*(a) = 1 Generalizes to any length chain Three Variables l0l0 l1l1
VaVa VbVb VcVc f(a) = 1 f(b) = 1 f(b) = 0 q c;0 q c;1 f*(c) = 0 f*(b) = 0f*(a) = 1 Dynamic Programming Three Variables l0l0 l1l1
Dynamic Programming 3 variables 2 variables + book-keeping n variables (n-1) variables + book-keeping Start from left, go to right Reparameterize current edge (a,b) M ab;k = min i { a;i + ab;ik } ’ ab;ik = ab;ik + M ab;k - M ab;k ’ b;k = b;k Repeat
Dynamic Programming Start from left, go to right Reparameterize current edge (a,b) M ab;k = min i { a;i + ab;ik } Repeat MessagesMessage Passing Why stop at dynamic programming? ’ ab;ik = ab;ik + M ab;k - M ab;k ’ b;k = b;k
VaVa VbVb VcVc Reparameterize the edge (c,b) as before Three Variables l0l0 l1l1
VaVa VbVb VcVc Reparameterize the edge (c,b) as before ’ b;i = q b;i Three Variables l0l0 l1l1
VaVa VbVb VcVc Reparameterize the edge (b,a) as before Three Variables l0l0 l1l1
VaVa VbVb VcVc Reparameterize the edge (b,a) as before ’ a;i = q a;i Three Variables l0l0 l1l1
VaVa VbVb VcVc Forward Pass Backward Pass All min-marginals are computed Three Variables l0l0 l1l1
Belief Propagation on Chains Start from left, go to right Reparameterize current edge (a,b) M ab;k = min i { a;i + ab;ik } ’ ab;ik = ab;ik + M ab;k - M ab;k ’ b;k = b;k Repeat till the end of the chain Start from right, go to left Repeat till the end of the chain
Belief Propagation on Chains A way of computing reparam constants Generalizes to chains of any length Forward Pass - Start to End MAP estimate Min-marginals of final variable Backward Pass - End to start All other min-marginals
Computational Complexity Each constant takes O(|L|) Number of constants - O(|E||L|) O(|E||L| 2 ) Memory required ? O(|E||L|)
Belief Propagation on Trees VbVb VaVa Forward Pass: Leaf Root All min-marginals are computed Backward Pass: Root Leaf VcVc VdVd VeVe VgVg VhVh
Outline Problem Formulation Reparameterization Energy Minimization for Trees Loopy Belief Propagation Pearl, 1988; Murphy et al., 1999
Belief Propagation on Cycles VaVa VbVb VdVd VcVc Where do we start? Arbitrarily a;0 a;1 b;0 b;1 d;0 d;1 c;0 c;1 Reparameterize (a,b)
Belief Propagation on Cycles VaVa VbVb VdVd VcVc a;0 a;1 ’ b;0 ’ b;1 d;0 d;1 c;0 c;1 Potentials along the red path add up to 0
Belief Propagation on Cycles VaVa VbVb VdVd VcVc a;0 a;1 ’ b;0 ’ b;1 d;0 d;1 ’ c;0 ’ c;1 Potentials along the red path add up to 0
Belief Propagation on Cycles VaVa VbVb VdVd VcVc a;0 a;1 ’ b;0 ’ b;1 ’ d;0 ’ d;1 ’ c;0 ’ c;1 Potentials along the red path add up to 0
Belief Propagation on Cycles VaVa VbVb VdVd VcVc ’ a;0 ’ a;1 ’ b;0 ’ b;1 ’ d;0 ’ d;1 ’ c;0 ’ c;1 Potentials along the red path add up to 0
Belief Propagation on Cycles VaVa VbVb VdVd VcVc ’ a;0 ’ a;1 ’ b;0 ’ b;1 ’ d;0 ’ d;1 ’ c;0 ’ c;1 Potentials along the red path add up to 0 - a;0 - a;1
Belief Propagation on Cycles VaVa VbVb VdVd VcVc a;0 a;1 b;0 b;1 d;0 d;1 c;0 c;1 Any suggestions?Fix V a to label l 0
Belief Propagation on Cycles VaVa VbVb VdVd VcVc Any suggestions?Fix V a to label l 0 a;0 b;0 b;1 d;0 d;1 c;0 c;1 Equivalent to a tree-structured problem
Belief Propagation on Cycles VaVa VbVb VdVd VcVc a;1 b;0 b;1 d;0 d;1 c;0 c;1 Any suggestions?Fix V a to label l 1 Equivalent to a tree-structured problem
Belief Propagation on Cycles Choose the minimum energy solution VaVa VbVb VdVd VcVc a;0 a;1 b;0 b;1 d;0 d;1 c;0 c;1 This approach quickly becomes infeasible
Loopy Belief Propagation V1V1 V2V2 V3V3 V4V4 V5V5 V6V6 V7V7 V8V8 V9V9 Keep reparameterizing edges in some order Hope for convergence and a good solution
Belief Propagation Generalizes to any arbitrary random field Complexity per iteration ? O(|E||L| 2 ) Memory required ? O(|E||L|)
Theoretical Properties of BP Exact for Trees Pearl, 1988 What about any general random field? Run BP. Assume it converges.
Theoretical Properties of BP Exact for Trees Pearl, 1988 What about any general random field? Choose variables in a tree. Change their labels. Value of energy does not decrease
Theoretical Properties of BP Exact for Trees Pearl, 1988 What about any general random field? Choose variables in a cycle. Change their labels. Value of energy does not decrease
Theoretical Properties of BP Exact for Trees Pearl, 1988 What about any general random field? For cycles, if BP converges then exact MAP Weiss and Freeman, 2001
Speed-Ups for Special Cases ab;ik = 0, if i = k = C, otherwise. M ab;k = min i { a;i + ab;ik } Felzenszwalb and Huttenlocher, 2004
Speed-Ups for Special Cases ab;ik = w ab |i-k| M ab;k = min i { a;i + ab;ik } Felzenszwalb and Huttenlocher, 2004
Speed-Ups for Special Cases ab;ik = min{w ab |i-k|, C} M ab;k = min i { a;i + ab;ik } Felzenszwalb and Huttenlocher, 2004
Speed-Ups for Special Cases ab;ik = min{w ab (i-k) 2, C} M ab;k = min i { a;i + ab;ik } Felzenszwalb and Huttenlocher, 2004