Probabilistic Fitting
Marcel LΓΌthi, University of Basel
1
Analysis by Synthesis - Idea
Belief: Understanding means being able to synthesize it
Parameters π
Comparison
Update π Synthesis π(π)
Analysis by Synthesis β Modelling problem
Modelling problem: What are π(π) and π π· π)
Parameters π
Comparison: π D π)
Update π Synthesis π(π)
Prior π(π)
Analysis by synthesis β Conceptual problem
Parameters π
Comparison: π D π)
Update π Synthesis
π(π)
Prior π(π)
Updating beliefs through Bayesian inference
π π D = π π π D π
β« π π π π· π ππ
Analysis by synthesis β Computational problem
5
π π D = π π π D π
β« π π π π· π ππ
Usually non-linear and expensive to evaluate
High-Dimensional integral
ΰΆ± ΰΆ± β¦ ΰΆ±π π 1 , β¦ , π π π π· π 1 , β¦ , π π )ππ 1 β¦ π π π 1 π π
Can only be
approximated
Outline
β’ Basic idea: Sampling methods and MCMC
β’ The Metropolis-Hastings algorithm
β’ The Metropolis algorithm
β’ Implementing the Metropolis algorithm
β’ The Metropolis-Hastings algorithm
β’ Example: 3D Landmark fitting
Variational methods
β’ Function approximation π(π) arg max
π KL(π(π)|π(π|π·))
Sampling methods
β’ Numeric approximations through simulation
Approximate Bayesian Inference
KL: Kullback- Leibler divergence
π π
π
π
β’ Simulate a distribution π through random samples π₯ π
β’ Evaluate expectation (of some function π of random variable π)
πΈ π(π) = ΰΆ± π π₯ π π₯ ππ₯
πΈ π(π) β α π = 1 π ΰ·
π π
π π₯ π , π₯ π ~ π π₯
π α π(π) ~ π 1 π
Sampling Methods
β’ βIndependentβ of dimensionality of π
β’ More samples increase accuracy
This is difficult!
π
Sampling from a Distribution
β’ Easy for standard distributions β¦ is it?
β’ Uniform
β’ Gaussian
β’ How to sample from more complex distributions?
β’ Beta, Exponential, Chi square, Gamma, β¦
β’ Posteriors are very often not in a βniceβ standard text book form
β’ We need to sample from an unknown posterior with only unnormalized, expensive point- wise evaluation ο
9
Random.nextDouble()
Random.nextGaussian()
Markov Chain Monte Carlo
Markov Chain Monte Carlo Methods (MCMC)
Idea: Design a Markov Chain such that samples π₯ obey the target distribution π Concept: βUse an already existing sample to produce the next oneβ
β’ Many successful practical applications
β’ Proven: developed in the 1950/1970ies (Metropolis/Hastings)
β’ Direct mapping of computing power to approximation accuracy
MCMC: An ingenious mathematical construction
Markov chain
Equilibrium
distribution Distribution π(π₯)
MCMC Algorithms induces
converges to Generate samples
from is
If Markov Chain is a- periodic and
irreducable itβ¦
β¦ an aperiodic and irreducable
No need to understand this now: more details follow!
The Metropolis Algorithm
β’ Initialize with sample π
β’ Generate next sample, with current sample π
1. Draw a sample π β² from π(π β² |π) (βproposalβ) 2. With probability πΌ = min π π β²
π π , 1 accept π β² as new state π 3. Emit current state π as sample
Requirements:
β’ Proposal distribution π(π β² |π) β must generate samples, symmetric
β’ Target distribution π π β with point-wise evaluation Result:
β’ Stream of samples approximately from π π
Jupyter-Notebook β Metropolis-Hastings.ipynb
The Metropolis-Hastings Algorithm
β’ Initialize with sample π
β’ Generate next sample, with current sample π
1. Draw a sample π β² from π(π β² |π) (βproposalβ) 2. With probability πΌ = min π π₯ β²
π π₯
π π₯|π₯ β²
π π₯ β² |π₯ , 1 accept π β² as new state π 3. Emit current state π as sample
β’ Generalization of Metropolis algorithm to asymmetric Proposal distribution π π β² π β π π π β²
π π β² π > 0 β π π π β² > 0
Properties
β’ Approximation: Samples π₯ 1 , π₯ 2 , β¦ approximate π(π₯)
Unbiased but correlated (not i.i.d.)
β’ Normalization: π(π₯) does not need to be normalized
Algorithm only considers ratios π(π₯β²)/π(π₯)
β’ Dependent Proposals: π π₯ β² π₯ depends on current sample π₯
Algorithm adapts to target with simple 1-step memory
Metropolis - Hastings: Limitations
β’ Highly correlated targets
Proposal should match target to avoid too many rejections
β’ Serial correlation
β’ Results from rejection and too small stepping
β’ Subsampling
Bishop. PRML, Springer, 2006
β’ Metropolis algorithm formalizes: propose-and-verify
β’ Steps are completely independent.
Propose
Draw a sample π₯ β² from π(π₯ β² |π₯)
Verify
With probability πΌ = min π π₯ β²
π π₯
π π₯|π₯ β²
π π₯ β² |π₯ , 1 accept π β² as new sample
Propose-and-Verify Algorithm
19
MH as Propose and Verify
β’ Decouples the steps of finding the solution from validating a solution
β’ Natural to integrate uncertain proposals Q
(e.g. automatically detected landmarks, ...)
β’ Possibility to include βlocal optimizationβ (e.g. a ICP or ASM updates, gradient step, β¦) as proposal
Anything more βinformedβ than random walk should improve convergence.
Fitting 3D Landmarks
3D Alignment with Shape and Pose
21
3D Fitting Example
right.eye.corner_outer left.eye.corner_outer
right.lips.corner left.lips.corner