Professional Documents
Culture Documents
1
1 1 1 2 2
𝑃 ( 𝑏 = 𝑓𝑎𝑙𝑠𝑒 ) = + + +… = =
2 8 16
1− ( )
1
4
3
Halo multiplayer
• In this talk..
– Formal semantics of
probabilistic programs
– Inference is program analysis
Prob : A simple imperative language for prob.
programs
types
; declaration
expressions
variable
constant
binary operation
unary operation
statements
deterministic assignment
probabilistic assignment
observe
skip
sequential composition
conditional composition
loop
programs
Semantics
• States: , valuation to all variables
• Probabilistic semantics:
Starting at state , and statement , the program ran by
generating samples and terminated in state with probability
,
if
if
Transition rules (2)
,
if
,
if
,
if
,
if
,
if
Semantics = Expectation
Let be the return expression of the program
otherwise
,
Inference = Program Analysis
𝑥 𝑦 • Represents
• There is no dependence between and
• On the other hand, if (or some descendant of )
is observed, then depends on and vice versa
𝑧
A new notion of influence
Theorem: P = Pre(P)
observe(maryWakes && phoneWorking);
}
else if (alarm){
maryWakes = Bernoulli(0.6);
observe(maryWakes && phoneWorking);
}
else {
maryWakes = Bernoulli(0.2);
observe(maryWakes && phoneWorking);
}
called = maryWakes && phoneWorking;
return burglary;
}
Background: MH sampling
𝑄 ( 𝑥 ; 𝑥′ )
𝑥
1. Draw samples for from a proposal
2. Compute
3. If , accept else accept with probability
c2 = Bernoulli(0.5); c1 t t 1/4
observe(c1 || c2); t f 1/4
t 1/2
return (c1, c2); f t 1/4
f f 1/4
f 1/2
𝑜𝑏𝑠𝑒𝑟𝑣𝑒(𝑐 1∨¿ 𝑐 2)
c1 c2 Normalize c1 c2
t t 1/3 t t 1/4
t f 1/3 t f 1/4
f t 1/3 f t 1/4
Data flow analysis with ADDs
bool c1, c2;
c1 = Bernoulli(0.5); c1 = Bernoulli(0.5) c2 = Bernoulli(0.5)
c2 = Bernoulli(0.5);
observe(c1 || c2);
return (c1, c2); 𝟏
𝟐
𝟏
𝟒
observe(c1 || c2)
𝒄𝟏 𝒄𝟏
0 Normalize 0
𝒄𝟐 𝟏 𝟏
𝒄𝟐
0 𝟏 0 𝟏
𝟎 𝟏
𝟑 𝟎 𝟏
𝟒
Guillaume Claret, Sriram K. Rajamani, Aditya V. Nori, Andrew D. Gordon, and Johannes
Borgström. Bayesian Inference Using Data Flow Analysis. In ESEC-FSE '13: Foundations of
Software Engineering, August 2013
Part III: Applications
Training Set
o Training set: , ,
ML Training Algorithm
o Test set:
,
o is an ML classification
Test Set Classifier Class Labels algorithm
Evaluation Phase
Debugging Classification Tasks
Training Phase
An assignment to
input variables is a
world.
Probabilistic program to compute
Take 1, simple version Take 2, optimized version
𝑃𝑆 ( 𝑌 𝑖 )= ∑ 𝑝 (𝑤)
𝑤∨ 𝑓 (𝑤 [ 𝑌 𝑖 ← 𝑦 𝑖] ) =𝑥 ∧ 𝑋 ≠ 𝑥∧ 𝑌 𝑖 ≠ 𝑦 𝑖
Background on training
Training learns function
The classifier is a wrapper around :
if and if
Until (
Call the result
Approximating for ’ close to
Logistic
regression
Decision
Trees
Aleks Chakarov, Aditya Nori, Sriram K. Rajamani, Selva Samuel, Shayak Sen,
Deepak Vijaykeerthy. Towards Debugging Machine Learning Tasks. Under review
Part IV: Tools
MoG:
Exact Approximate
Symbolic computations on MoG (2)
Compiler to symbolically compute
likelihoods
http://research.microsoft.com/en-us/projects/r2/
Questions?
Motivation
• Programs are increasingly “data driven”
instead of “algorithm driven”
– Use ML to build models from data, and then use
models to make decisions
– Many domains: search engines, social networks,
speech recognition, computer vision, medical
diagnostic aids, etc.
• Our goal: programming abstractions, compiler,
runtime, and tools for such programs