CS 188: Artificil Intelligence Fll 2009 Lecture 20: Prticle Filtering 11/5/2009 Dn Klein UC Berkeley Announcements Written 3 out: due 10/12 Project 4 out: due 10/19 Written 4 proly xed, Project 5 moving up Course contest updte Dily tournments re now eing run! Instructions for registrtion on the wesite Qulifying opens soon: 1% on finl exm! 2 1
Recp: Resoning Over Time Sttionry Mrkov models 0.3 X 1 X 2 X 3 X 4 rin sun 0.7 0.3 0.7 Hidden Mrkov models X 1 X 2 X 3 X 4 X 5 E 2 E 3 E 4 E 5 X E P rin umrell 0.9 rin no umrell 0.1 sun umrell 0.2 sun no umrell 0.8 Recp: Filtering Elpse time: compute P( X t e 1:t-1 ) Oserve: compute P( X t e 1:t ) X 1 X 2 Belief: <P(rin), P(sun)> <0.5, 0.5> Prior on X 1 <0.82, 0.18> Oserve E 2 <0.63, 0.37> Elpse time <0.88, 0.12> Oserve 2
Prticle Filtering Filtering: pproximte solution Sometimes X is too ig to use exct inference X my e too ig to even store B(X) E.g. X is continuous Solution: pproximte inference Trck smples of X, not ll vlues Smples re clled prticles Time per step is liner in the numer of smples But: numer needed my e lrge In memory: list of prticles, not sttes This is how root locliztion works in prctice 0.0 0.1 0.0 0.0 0.0 0.2 0.0 0.2 0.5 Prticle Filtering: Elpse Time Ech prticle is moved y smpling its next position from the trnsition model This is like prior smpling smples frequencies reflect the trnsition pros Here, most smples move clockwise, ut some move in nother direction or sty in plce This cptures the pssge of time If we hve enough smples, close to the exct vlues efore nd fter (consistent) 3
Prticle Filtering: Oserve Slightly trickier: We don t smple the oservtion, we fix it This is similr to likelihood weighting, so we downweight our smples sed on the evidence Note tht, s efore, the proilities don t sum to one, since most hve een downweighted (in fct they sum to n pproximtion of P(e)) Prticle Filtering: Resmple Rther thn trcking weighted smples, we resmple N times, we choose from our weighted smple distriution (i.e. drw with replcement) This is equivlent to renormlizing the distriution Now the updte is complete for this time step, continue with the next one 4
Prticle Filtering Sometimes X is too ig to use exct inference X my e too ig to even store B(X) E.g. X is continuous X 2 my e too ig to do updtes Solution: pproximte inference Trck smples of X, not ll vlues Smples re clled prticles Time per step is liner in the numer of smples But: numer needed my e lrge In memory: list of prticles, not sttes 0.0 0.1 0.0 0.0 0.0 0.2 0.0 0.2 0.5 This is how root locliztion works in prctice Representtion: Prticles Our representtion of P(X) is now list of N prticles (smples) Generlly, N << X Storing mp from X to counts would defet the point P(x) pproximted y numer of prticles with vlue x So, mny x will hve P(x) = 0! More prticles, more ccurcy For now, ll prticles hve weight of 1 Prticles: (3,3) (2,3) (3,3) (3,2) (3,3) (3,2) (2,1) (3,3) (3,3) (2,1) 15 5
Prticle Filtering: Elpse Time Ech prticle is moved y smpling its next position from the trnsition model This is like prior smpling smples frequencies reflect the trnsition pros Here, most smples move clockwise, ut some move in nother direction or sty in plce This cptures the pssge of time If we hve enough smples, close to the exct vlues efore nd fter (consistent) Prticle Filtering: Oserve Slightly trickier: Don t do rejection smpling (why not?) We don t smple the oservtion, we fix it This is similr to likelihood weighting, so we downweight our smples sed on the evidence Note tht, s efore, the proilities don t sum to one, since most hve een downweighted (in fct they sum to n pproximtion of P(e)) 6
Prticle Filtering: Resmple Rther thn trcking weighted smples, we resmple N times, we choose from our weighted smple distriution (i.e. drw with replcement) This is equivlent to renormlizing the distriution Now the updte is complete for this time step, continue with the next one Old Prticles: (3,3) w=0.1 (2,1) w=0.9 (2,1) w=0.9 (3,1) w=0.4 (3,2) w=0.3 (2,2) w=0.4 (1,1) w=0.4 (3,1) w=0.4 (2,1) w=0.9 (3,2) w=0.3 Old Prticles: (2,1) w=1 (2,1) w=1 (2,1) w=1 (3,2) w=1 (2,2) w=1 (2,1) w=1 (1,1) w=1 (3,1) w=1 (2,1) w=1 (1,1) w=1 In root locliztion: Root Locliztion We know the mp, ut not the root s position Oservtions my e vectors of rnge finder redings Stte spce nd redings re typiclly continuous (works siclly like very fine grid) nd so we cnnot store B(X) Prticle filtering is min technique [Demos] 7
P4: Ghostusters 2.0 (et) Plot: Pcmn's grndfther, Grndpc, lerned to hunt ghosts for sport. He ws linded y his power, ut could her the ghosts nging nd clnging. Trnsition Model: All ghosts move rndomly, ut re sometimes ised Noisy distnce pro True distnce = 8 15 13 11 9 7 5 Emission Model: Pcmn knows noisy distnce to ech ghost 3 1 [Demo] Dynmic Byes Nets (DBNs) We wnt to trck multiple vriles over time, using multiple sources of evidence Ide: Repet fixed Byes net structure t ech time Vriles from time t cn condition on those from t-1 t =1 t =2 t =3 G 1 G 2 G 3 G 1 G 2 G 3 E 2 E 2 E 3 E 3 Discrete vlued dynmic Byes nets re lso HMMs 8
Exct Inference in DBNs Vrile elimintion pplies to dynmic Byes nets Procedure: unroll the network for T time steps, then eliminte vriles until P(X T e 1:T ) is computed t =1 t =2 t =3 G 1 G 2 G 3 G 1 G 2 G 3 E 2 E 2 E 3 E 3 Online elief updtes: Eliminte ll vriles from the previous time step; store fctors for current time only 22 DBN Prticle Filters A prticle is complete smple for time step Initilize: Generte prior smples for the t=1 Byes net Exmple prticle: G 1 = (3,3) G 1 = (5,3) Elpse time: Smple successor for ech prticle Exmple successor: G 2 = (2,3) G 2 = (6,3) Oserve: Weight ech entire smple y the likelihood of the evidence conditioned on the smple Likelihood: P( G 1 ) * P( G 1 ) Resmple: Select prior smples (tuples of vlues) in proportion to their likelihood [Demo] 23 9
SLAM SLAM = Simultneous Locliztion And Mpping We do not know the mp or our loction Our elief stte is over mps nd positions! Min techniques: Klmn filtering (Gussin HMMs) nd prticle methods [DEMOS] DP-SLAM, Ron Prr 10