SlideShare a Scribd company logo
1 of 58
Computer vision: models,
 learning and inference
           Chapter 10
        Graphical Models



   Please send errata to s.prince@cs.ucl.ac.uk
Independence
•   Two variables x1 and x2 are independent if their
    joint probability distribution factorizes as
    Pr(x1, x2)=Pr(x1) Pr(x2)




           Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   2
Conditional independence
•   The variable x1 is said to be conditionally
    independent of x3 given x2 when x1 and x3 are
    independent for fixed x2.



•   When this is true the joint density factorizes in a
    certain way and is hence redundant.




           Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   3
Conditional independence




•   Consider joint pdf of three discrete variables x1, x2, x3




                  Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   4
Conditional independence




•   Consider joint pdf of three discrete variables x1, x2, x3
     • The three marginal distributions show that no pair of variables is independent



                 Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   5
Conditional independence




•   Consider joint pdf of three discrete variables x1, x2, x3
     • The three marginal distributions show that no pair of variables is independent
     • But x1 is independent of x2 given x3


                 Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   6
Graphical models
• A graphical model is a graph based
  representation that makes both factorization
  and conditional independence relations easy
  to establish

• Two important types:
  – Directed graphical model or Bayesian network
  – Undirected graphical model or Markov network

         Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   7
Directed graphical models
• Directed graphical model represents probability
  distribution that factorizes as a product of
  conditional probability distributions



 where pa[n] denotes the parents of node n




          Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   8
Directed graphical models
• To visualize graphical model from factorization
   – add one node per random variable and draw arrow to each
     variable from each of its parents.


• To extract factorization from graphical model
   – Add one term per node in the graph Pr(xn| xpa[n])
   – If no parents then just add Pr(xn)




           Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   9
Example 1




Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   10
Example 1




= Markov Blanket of variable x8 – Parents, children
     and parents of children
     Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   11
Example 1




If there is no route between to variables and they
share no ancestors they are independent.
       Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   12
Example 1




A variable is conditionally independent of all others
given its Markov Blanket
         Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   13
Example 1




General rule:




                Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   14
Example 2



This joint pdf of this graphical model factorizes as:




            Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   15
Example 2



This joint pdf of this graphical model factorizes as:


It describes the original example:




            Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   16
Example 2



 Here the arrows meet head to tail at x2 and so x1 is
 conditionally independent of x3 given x2.


General rule:




                Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   17
Example 2


Algebraic proof:




 No dependence on x3 implies that x1 is conditionally
 independent of x3 given x2.
           Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   18
Redundancy
                        Conditional independence can be
                        thought of as redundancy in the full
                        distribution




                                                             4           +              3x4   +   2x3

      4 x 3 x 2 = 24 entries                                 = 22 entries

Redundancy here only very small, but with larger models
can be very significant.
             Computer vision: models, learning and inference. ©2011 Simon J.D. Prince              19
Example 3




      Mixture of                       t-distribution                                Factor analyzer
      Gaussians
Blue boxes = Plates. Interpretation: repeat contents of box
number of times in bottom right corner.
Bullet = variables which are not treated as uncertain
          Computer vision: models, learning and inference. ©2011 Simon J.D. Prince              20
Undirected graphical models
Probability distribution factorizes as:




   Partition                    Product over                         Potential function
   function                      C functions                           (returns non-
(normalization                                                       negative number)
  constant)
         Computer vision: models, learning and inference. ©2011 Simon J.D. Prince     21
Undirected graphical models
Probability distribution factorizes as:




   Partition
   function
(normalization                  For large systems, intractable to compute
  constant)
         Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   22
Alternative form


Can be written as Gibbs Distribution:




where                                                         Cost function
                                                           (positive or negative)
         Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   23
Cliques
Better to write undirected model as




                              Product over                              Clique
                                 cliques                           Subset of variables

        Computer vision: models, learning and inference. ©2011 Simon J.D. Prince    24
Undirected graphical models
• To visualize graphical model from factorization
   – Draw one node per random variable
   – For every clique draw connection from every node to
     every other


• To extract factorization from graphical model
   – Add one term to factorization per maximal clique (fully
     connected subset of nodes where it is not possible to add
     another node and remain fully connected)


           Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   25
Conditional independence
• Much simpler than for directed models:

One set of nodes is conditionally independent of another
 given a third if the third set separates them (i.e.
 Blocks any path from the first node to the second)




          Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   26
Example 1



Represents factorization:




          Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   27
Example 1



By inspection of graphical model:

x1 is conditionally independent of x3 given x2 as the
route from x1 to x3 is blocked by x2.




          Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   28
Example 1


Algebraically:




No dependence on x3 implies that x1 is conditionally
independent of x3 given x2.
           Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   29
Example 2




• Variables x1 and x2 form a clique (both connected to
  each other)
• But not a maximal clique as we can add x3 and it is
  connected to both
         Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   30
Example 2




Graphical model implies factorization:



           Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   31
Example 2




Or could be....

                                                  ... but this is less general
           Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   32
Comparing directed and undirected models

Executive summary:

•   Some conditional independence patterns can be
    represented by both directed and undirected
•   Some can be represented only by directed
•   Some can be represented only by undirected
•   Some can be represented by neither




          Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   33
Comparing directed and undirected models




These models represents same independence /                             There is no undirected model that
conditional independence relations                                      can describe these relations

               Computer vision: models, learning and inference. ©2011 Simon J.D. Prince             34
Comparing directed and undirected models




   There is no directed model that                                 Closest example,
   can describe these relations                                    but not the same
            Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   35
Graphical models in computer vision




     Chain model                                       Interpreting sign
(hidden Markov model)                                language sequences


         Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   36
Graphical models in computer vision




  Tree model                                       Parsing the human
                                                          body

      Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   37
Graphical models in computer vision




    Grid model                                                Semantic
Markov random field                                         segmentation
   (blue nodes)
        Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   38
Graphical models in computer vision




 Chain model                                          Tracking contours
 Kalman filter

      Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   39
Inference in models with many
               unknowns
• Ideally we would compute full posterior
  distribution Pr(w1...N|x1...N).
• But for most models this is a very large
  discrete distribution – intractable to compute
• Other solutions:
  – Find MAP solution
  – Find marginal posterior distributions
  – Maximum marginals
  – Sampling posterior

         Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   40
Finding MAP solution




• Still difficult to compute – must search
  through very large number of states to find
  the best one.


         Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   41
Marginal posterior distributions




• Compute one distribution for each variable wn.
• Obviously cannot be computed by computing
  full distribution and explicitly marginalizing.


         Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   42
Maximum marginals




• Maximum of marginal posterior distribution for
  each variable wn.
• May have probability zero; the states can be
  individually probably but never co-occur.

        Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   43
Sampling the posterior
• Draw samples from posterior Pr(w1...N|x1...N).
  – use samples as representation of distribution
  – select sample with highest prob. as point sample
  – compute empirical max-marginals
     • Look at marginal statistics of samples




          Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   44
Drawing samples - directed



To sample from directed model, use ancestral sampling

•   work through graphical model, sampling one variable at
    a time.
•   Always sample parents before sampling variable
•   Condition on previously sampled values



           Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   45
Ancestral sampling example




  Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   46
Ancestral sampling example




To generate one sample:
1. Sample x1* from Pr(x1)                               4. Sample x3* from Pr(x3| x2*,x4*)
2. Sample x2* from Pr(x2| x1*)                          5. Sample x5* from Pr(x5| x3*)
3. Sample x4* from Pr(x4| x1*, x2*)
             Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   47
Drawing samples - undirected
• Can’t use ancestral sampling as no sense of
  parents / children and don’t have conditional
  probability distributions
• Instead us Markov chain Monte Carlo method
  – Generate series of samples (chain)
  – Each depends on previous sample (Markov)
  – Generation stochastic (Monte Carlo)
• Example MCMC method = Gibbs sampling

         Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   48
Gibbs sampling
To generate new sample x in the chain
  – Sample each dimension in any order
  – To update nth dimension xn
    •   Fix other N-1 dimensions
    •   Draw from conditional distribution Pr(xn| x1...Nn)
Get samples by selecting from chain
  – Needs burn in period
  – Choose samples spaced apart so not correlated

         Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   49
Gibbs sampling example: bi-variate
        normal distribution




     Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   50
Gibbs sampling example: bi-variate
        normal distribution




     Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   51
Learning in directed models



Use standard ML formulation




where xi,n is the nth dimension of the ith training example.
           Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   52
Learning in undirected models
Write in form of Gibbs distribution




Maximum likelihood formulation




       Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   53
Learning in undirected models




PROBLEM: To compute first term, we must sum over
all possible states. This is intractable



         Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   54
Contrastive divergence
Some algebraic manipulation




         Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   55
Contrastive divergence
   Now approximate:




Where xj* is one of J samples from the distribution.
Can be computed using Gibbs sampling. In practice, it is
possible to run MCMC for just 1 iteration and still OK.
           Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   56
Contrastive divergence




Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   57
Conclusions
Can characterize joint distributions as
  – Graphical models
  – Sets of conditional independence relations
  – Factorizations
Two types of graphical model, represent
  different but overlapping subsets of possible
  conditional independence relations
  – Directed (learning easy, sampling easy)
  – Undirected (learning hard, sampling hard)

         Computer vision: models, learning and inference. ©2011 Simon J.D. Prince   58

More Related Content

Similar to 10 cv mil_graphical_models

Introduction to Probability
Introduction to ProbabilityIntroduction to Probability
Introduction to ProbabilityLukas Tencer
 
17 cv mil_models_for_shape
17 cv mil_models_for_shape17 cv mil_models_for_shape
17 cv mil_models_for_shapezukun
 
08 cv mil_regression
08 cv mil_regression08 cv mil_regression
08 cv mil_regressionzukun
 
02 cv mil_intro_to_probability
02 cv mil_intro_to_probability02 cv mil_intro_to_probability
02 cv mil_intro_to_probabilityzukun
 
20 cv mil_models_for_words
20 cv mil_models_for_words20 cv mil_models_for_words
20 cv mil_models_for_wordszukun
 
15 cv mil_models_for_transformations
15 cv mil_models_for_transformations15 cv mil_models_for_transformations
15 cv mil_models_for_transformationszukun
 
13 cv mil_preprocessing
13 cv mil_preprocessing13 cv mil_preprocessing
13 cv mil_preprocessingzukun
 
16 cv mil_multiple_cameras
16 cv mil_multiple_cameras16 cv mil_multiple_cameras
16 cv mil_multiple_cameraszukun
 
Graphical Models for chains, trees and grids
Graphical Models for chains, trees and gridsGraphical Models for chains, trees and grids
Graphical Models for chains, trees and gridspotaters
 
05 cv mil_normal_distribution
05 cv mil_normal_distribution05 cv mil_normal_distribution
05 cv mil_normal_distributionzukun
 
18 cv mil_style_and_identity
18 cv mil_style_and_identity18 cv mil_style_and_identity
18 cv mil_style_and_identityzukun
 
06 cv mil_learning_and_inference
06 cv mil_learning_and_inference06 cv mil_learning_and_inference
06 cv mil_learning_and_inferencezukun
 
14 cv mil_the_pinhole_camera
14 cv mil_the_pinhole_camera14 cv mil_the_pinhole_camera
14 cv mil_the_pinhole_camerazukun
 
Unsupervised Learning (D2L6 2017 UPC Deep Learning for Computer Vision)
Unsupervised Learning (D2L6 2017 UPC Deep Learning for Computer Vision)Unsupervised Learning (D2L6 2017 UPC Deep Learning for Computer Vision)
Unsupervised Learning (D2L6 2017 UPC Deep Learning for Computer Vision)Universitat Politècnica de Catalunya
 

Similar to 10 cv mil_graphical_models (14)

Introduction to Probability
Introduction to ProbabilityIntroduction to Probability
Introduction to Probability
 
17 cv mil_models_for_shape
17 cv mil_models_for_shape17 cv mil_models_for_shape
17 cv mil_models_for_shape
 
08 cv mil_regression
08 cv mil_regression08 cv mil_regression
08 cv mil_regression
 
02 cv mil_intro_to_probability
02 cv mil_intro_to_probability02 cv mil_intro_to_probability
02 cv mil_intro_to_probability
 
20 cv mil_models_for_words
20 cv mil_models_for_words20 cv mil_models_for_words
20 cv mil_models_for_words
 
15 cv mil_models_for_transformations
15 cv mil_models_for_transformations15 cv mil_models_for_transformations
15 cv mil_models_for_transformations
 
13 cv mil_preprocessing
13 cv mil_preprocessing13 cv mil_preprocessing
13 cv mil_preprocessing
 
16 cv mil_multiple_cameras
16 cv mil_multiple_cameras16 cv mil_multiple_cameras
16 cv mil_multiple_cameras
 
Graphical Models for chains, trees and grids
Graphical Models for chains, trees and gridsGraphical Models for chains, trees and grids
Graphical Models for chains, trees and grids
 
05 cv mil_normal_distribution
05 cv mil_normal_distribution05 cv mil_normal_distribution
05 cv mil_normal_distribution
 
18 cv mil_style_and_identity
18 cv mil_style_and_identity18 cv mil_style_and_identity
18 cv mil_style_and_identity
 
06 cv mil_learning_and_inference
06 cv mil_learning_and_inference06 cv mil_learning_and_inference
06 cv mil_learning_and_inference
 
14 cv mil_the_pinhole_camera
14 cv mil_the_pinhole_camera14 cv mil_the_pinhole_camera
14 cv mil_the_pinhole_camera
 
Unsupervised Learning (D2L6 2017 UPC Deep Learning for Computer Vision)
Unsupervised Learning (D2L6 2017 UPC Deep Learning for Computer Vision)Unsupervised Learning (D2L6 2017 UPC Deep Learning for Computer Vision)
Unsupervised Learning (D2L6 2017 UPC Deep Learning for Computer Vision)
 

More from zukun

My lyn tutorial 2009
My lyn tutorial 2009My lyn tutorial 2009
My lyn tutorial 2009zukun
 
ETHZ CV2012: Tutorial openCV
ETHZ CV2012: Tutorial openCVETHZ CV2012: Tutorial openCV
ETHZ CV2012: Tutorial openCVzukun
 
ETHZ CV2012: Information
ETHZ CV2012: InformationETHZ CV2012: Information
ETHZ CV2012: Informationzukun
 
Siwei lyu: natural image statistics
Siwei lyu: natural image statisticsSiwei lyu: natural image statistics
Siwei lyu: natural image statisticszukun
 
Lecture9 camera calibration
Lecture9 camera calibrationLecture9 camera calibration
Lecture9 camera calibrationzukun
 
Brunelli 2008: template matching techniques in computer vision
Brunelli 2008: template matching techniques in computer visionBrunelli 2008: template matching techniques in computer vision
Brunelli 2008: template matching techniques in computer visionzukun
 
Modern features-part-4-evaluation
Modern features-part-4-evaluationModern features-part-4-evaluation
Modern features-part-4-evaluationzukun
 
Modern features-part-3-software
Modern features-part-3-softwareModern features-part-3-software
Modern features-part-3-softwarezukun
 
Modern features-part-2-descriptors
Modern features-part-2-descriptorsModern features-part-2-descriptors
Modern features-part-2-descriptorszukun
 
Modern features-part-1-detectors
Modern features-part-1-detectorsModern features-part-1-detectors
Modern features-part-1-detectorszukun
 
Modern features-part-0-intro
Modern features-part-0-introModern features-part-0-intro
Modern features-part-0-introzukun
 
Lecture 02 internet video search
Lecture 02 internet video searchLecture 02 internet video search
Lecture 02 internet video searchzukun
 
Lecture 01 internet video search
Lecture 01 internet video searchLecture 01 internet video search
Lecture 01 internet video searchzukun
 
Lecture 03 internet video search
Lecture 03 internet video searchLecture 03 internet video search
Lecture 03 internet video searchzukun
 
Icml2012 tutorial representation_learning
Icml2012 tutorial representation_learningIcml2012 tutorial representation_learning
Icml2012 tutorial representation_learningzukun
 
Advances in discrete energy minimisation for computer vision
Advances in discrete energy minimisation for computer visionAdvances in discrete energy minimisation for computer vision
Advances in discrete energy minimisation for computer visionzukun
 
Gephi tutorial: quick start
Gephi tutorial: quick startGephi tutorial: quick start
Gephi tutorial: quick startzukun
 
EM algorithm and its application in probabilistic latent semantic analysis
EM algorithm and its application in probabilistic latent semantic analysisEM algorithm and its application in probabilistic latent semantic analysis
EM algorithm and its application in probabilistic latent semantic analysiszukun
 
Object recognition with pictorial structures
Object recognition with pictorial structuresObject recognition with pictorial structures
Object recognition with pictorial structureszukun
 
Iccv2011 learning spatiotemporal graphs of human activities
Iccv2011 learning spatiotemporal graphs of human activities Iccv2011 learning spatiotemporal graphs of human activities
Iccv2011 learning spatiotemporal graphs of human activities zukun
 

More from zukun (20)

My lyn tutorial 2009
My lyn tutorial 2009My lyn tutorial 2009
My lyn tutorial 2009
 
ETHZ CV2012: Tutorial openCV
ETHZ CV2012: Tutorial openCVETHZ CV2012: Tutorial openCV
ETHZ CV2012: Tutorial openCV
 
ETHZ CV2012: Information
ETHZ CV2012: InformationETHZ CV2012: Information
ETHZ CV2012: Information
 
Siwei lyu: natural image statistics
Siwei lyu: natural image statisticsSiwei lyu: natural image statistics
Siwei lyu: natural image statistics
 
Lecture9 camera calibration
Lecture9 camera calibrationLecture9 camera calibration
Lecture9 camera calibration
 
Brunelli 2008: template matching techniques in computer vision
Brunelli 2008: template matching techniques in computer visionBrunelli 2008: template matching techniques in computer vision
Brunelli 2008: template matching techniques in computer vision
 
Modern features-part-4-evaluation
Modern features-part-4-evaluationModern features-part-4-evaluation
Modern features-part-4-evaluation
 
Modern features-part-3-software
Modern features-part-3-softwareModern features-part-3-software
Modern features-part-3-software
 
Modern features-part-2-descriptors
Modern features-part-2-descriptorsModern features-part-2-descriptors
Modern features-part-2-descriptors
 
Modern features-part-1-detectors
Modern features-part-1-detectorsModern features-part-1-detectors
Modern features-part-1-detectors
 
Modern features-part-0-intro
Modern features-part-0-introModern features-part-0-intro
Modern features-part-0-intro
 
Lecture 02 internet video search
Lecture 02 internet video searchLecture 02 internet video search
Lecture 02 internet video search
 
Lecture 01 internet video search
Lecture 01 internet video searchLecture 01 internet video search
Lecture 01 internet video search
 
Lecture 03 internet video search
Lecture 03 internet video searchLecture 03 internet video search
Lecture 03 internet video search
 
Icml2012 tutorial representation_learning
Icml2012 tutorial representation_learningIcml2012 tutorial representation_learning
Icml2012 tutorial representation_learning
 
Advances in discrete energy minimisation for computer vision
Advances in discrete energy minimisation for computer visionAdvances in discrete energy minimisation for computer vision
Advances in discrete energy minimisation for computer vision
 
Gephi tutorial: quick start
Gephi tutorial: quick startGephi tutorial: quick start
Gephi tutorial: quick start
 
EM algorithm and its application in probabilistic latent semantic analysis
EM algorithm and its application in probabilistic latent semantic analysisEM algorithm and its application in probabilistic latent semantic analysis
EM algorithm and its application in probabilistic latent semantic analysis
 
Object recognition with pictorial structures
Object recognition with pictorial structuresObject recognition with pictorial structures
Object recognition with pictorial structures
 
Iccv2011 learning spatiotemporal graphs of human activities
Iccv2011 learning spatiotemporal graphs of human activities Iccv2011 learning spatiotemporal graphs of human activities
Iccv2011 learning spatiotemporal graphs of human activities
 

Recently uploaded

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 

Recently uploaded (20)

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 

10 cv mil_graphical_models

  • 1. Computer vision: models, learning and inference Chapter 10 Graphical Models Please send errata to s.prince@cs.ucl.ac.uk
  • 2. Independence • Two variables x1 and x2 are independent if their joint probability distribution factorizes as Pr(x1, x2)=Pr(x1) Pr(x2) Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 2
  • 3. Conditional independence • The variable x1 is said to be conditionally independent of x3 given x2 when x1 and x3 are independent for fixed x2. • When this is true the joint density factorizes in a certain way and is hence redundant. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 3
  • 4. Conditional independence • Consider joint pdf of three discrete variables x1, x2, x3 Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 4
  • 5. Conditional independence • Consider joint pdf of three discrete variables x1, x2, x3 • The three marginal distributions show that no pair of variables is independent Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 5
  • 6. Conditional independence • Consider joint pdf of three discrete variables x1, x2, x3 • The three marginal distributions show that no pair of variables is independent • But x1 is independent of x2 given x3 Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 6
  • 7. Graphical models • A graphical model is a graph based representation that makes both factorization and conditional independence relations easy to establish • Two important types: – Directed graphical model or Bayesian network – Undirected graphical model or Markov network Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 7
  • 8. Directed graphical models • Directed graphical model represents probability distribution that factorizes as a product of conditional probability distributions where pa[n] denotes the parents of node n Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 8
  • 9. Directed graphical models • To visualize graphical model from factorization – add one node per random variable and draw arrow to each variable from each of its parents. • To extract factorization from graphical model – Add one term per node in the graph Pr(xn| xpa[n]) – If no parents then just add Pr(xn) Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 9
  • 10. Example 1 Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 10
  • 11. Example 1 = Markov Blanket of variable x8 – Parents, children and parents of children Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 11
  • 12. Example 1 If there is no route between to variables and they share no ancestors they are independent. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 12
  • 13. Example 1 A variable is conditionally independent of all others given its Markov Blanket Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 13
  • 14. Example 1 General rule: Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 14
  • 15. Example 2 This joint pdf of this graphical model factorizes as: Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 15
  • 16. Example 2 This joint pdf of this graphical model factorizes as: It describes the original example: Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 16
  • 17. Example 2 Here the arrows meet head to tail at x2 and so x1 is conditionally independent of x3 given x2. General rule: Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 17
  • 18. Example 2 Algebraic proof: No dependence on x3 implies that x1 is conditionally independent of x3 given x2. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 18
  • 19. Redundancy Conditional independence can be thought of as redundancy in the full distribution 4 + 3x4 + 2x3 4 x 3 x 2 = 24 entries = 22 entries Redundancy here only very small, but with larger models can be very significant. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 19
  • 20. Example 3 Mixture of t-distribution Factor analyzer Gaussians Blue boxes = Plates. Interpretation: repeat contents of box number of times in bottom right corner. Bullet = variables which are not treated as uncertain Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 20
  • 21. Undirected graphical models Probability distribution factorizes as: Partition Product over Potential function function C functions (returns non- (normalization negative number) constant) Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 21
  • 22. Undirected graphical models Probability distribution factorizes as: Partition function (normalization For large systems, intractable to compute constant) Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 22
  • 23. Alternative form Can be written as Gibbs Distribution: where Cost function (positive or negative) Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 23
  • 24. Cliques Better to write undirected model as Product over Clique cliques Subset of variables Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 24
  • 25. Undirected graphical models • To visualize graphical model from factorization – Draw one node per random variable – For every clique draw connection from every node to every other • To extract factorization from graphical model – Add one term to factorization per maximal clique (fully connected subset of nodes where it is not possible to add another node and remain fully connected) Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 25
  • 26. Conditional independence • Much simpler than for directed models: One set of nodes is conditionally independent of another given a third if the third set separates them (i.e. Blocks any path from the first node to the second) Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 26
  • 27. Example 1 Represents factorization: Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 27
  • 28. Example 1 By inspection of graphical model: x1 is conditionally independent of x3 given x2 as the route from x1 to x3 is blocked by x2. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 28
  • 29. Example 1 Algebraically: No dependence on x3 implies that x1 is conditionally independent of x3 given x2. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 29
  • 30. Example 2 • Variables x1 and x2 form a clique (both connected to each other) • But not a maximal clique as we can add x3 and it is connected to both Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 30
  • 31. Example 2 Graphical model implies factorization: Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 31
  • 32. Example 2 Or could be.... ... but this is less general Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 32
  • 33. Comparing directed and undirected models Executive summary: • Some conditional independence patterns can be represented by both directed and undirected • Some can be represented only by directed • Some can be represented only by undirected • Some can be represented by neither Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 33
  • 34. Comparing directed and undirected models These models represents same independence / There is no undirected model that conditional independence relations can describe these relations Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 34
  • 35. Comparing directed and undirected models There is no directed model that Closest example, can describe these relations but not the same Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 35
  • 36. Graphical models in computer vision Chain model Interpreting sign (hidden Markov model) language sequences Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 36
  • 37. Graphical models in computer vision Tree model Parsing the human body Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 37
  • 38. Graphical models in computer vision Grid model Semantic Markov random field segmentation (blue nodes) Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 38
  • 39. Graphical models in computer vision Chain model Tracking contours Kalman filter Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 39
  • 40. Inference in models with many unknowns • Ideally we would compute full posterior distribution Pr(w1...N|x1...N). • But for most models this is a very large discrete distribution – intractable to compute • Other solutions: – Find MAP solution – Find marginal posterior distributions – Maximum marginals – Sampling posterior Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 40
  • 41. Finding MAP solution • Still difficult to compute – must search through very large number of states to find the best one. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 41
  • 42. Marginal posterior distributions • Compute one distribution for each variable wn. • Obviously cannot be computed by computing full distribution and explicitly marginalizing. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 42
  • 43. Maximum marginals • Maximum of marginal posterior distribution for each variable wn. • May have probability zero; the states can be individually probably but never co-occur. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 43
  • 44. Sampling the posterior • Draw samples from posterior Pr(w1...N|x1...N). – use samples as representation of distribution – select sample with highest prob. as point sample – compute empirical max-marginals • Look at marginal statistics of samples Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 44
  • 45. Drawing samples - directed To sample from directed model, use ancestral sampling • work through graphical model, sampling one variable at a time. • Always sample parents before sampling variable • Condition on previously sampled values Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 45
  • 46. Ancestral sampling example Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 46
  • 47. Ancestral sampling example To generate one sample: 1. Sample x1* from Pr(x1) 4. Sample x3* from Pr(x3| x2*,x4*) 2. Sample x2* from Pr(x2| x1*) 5. Sample x5* from Pr(x5| x3*) 3. Sample x4* from Pr(x4| x1*, x2*) Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 47
  • 48. Drawing samples - undirected • Can’t use ancestral sampling as no sense of parents / children and don’t have conditional probability distributions • Instead us Markov chain Monte Carlo method – Generate series of samples (chain) – Each depends on previous sample (Markov) – Generation stochastic (Monte Carlo) • Example MCMC method = Gibbs sampling Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 48
  • 49. Gibbs sampling To generate new sample x in the chain – Sample each dimension in any order – To update nth dimension xn • Fix other N-1 dimensions • Draw from conditional distribution Pr(xn| x1...Nn) Get samples by selecting from chain – Needs burn in period – Choose samples spaced apart so not correlated Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 49
  • 50. Gibbs sampling example: bi-variate normal distribution Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 50
  • 51. Gibbs sampling example: bi-variate normal distribution Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 51
  • 52. Learning in directed models Use standard ML formulation where xi,n is the nth dimension of the ith training example. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 52
  • 53. Learning in undirected models Write in form of Gibbs distribution Maximum likelihood formulation Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 53
  • 54. Learning in undirected models PROBLEM: To compute first term, we must sum over all possible states. This is intractable Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 54
  • 55. Contrastive divergence Some algebraic manipulation Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 55
  • 56. Contrastive divergence Now approximate: Where xj* is one of J samples from the distribution. Can be computed using Gibbs sampling. In practice, it is possible to run MCMC for just 1 iteration and still OK. Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 56
  • 57. Contrastive divergence Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 57
  • 58. Conclusions Can characterize joint distributions as – Graphical models – Sets of conditional independence relations – Factorizations Two types of graphical model, represent different but overlapping subsets of possible conditional independence relations – Directed (learning easy, sampling easy) – Undirected (learning hard, sampling hard) Computer vision: models, learning and inference. ©2011 Simon J.D. Prince 58