Served as Technical Lead for language evaluation for the DARPA program
Probabilistic Programming for Advancing Machine Learning (PPAML)
PPL Publications
A disconnect between the "user language" and "developer language"
X
3
?
Combinators transform code before compilation
Advantages
julia> nuts(m(:x), data=data, numSamples=10).samples
(μ = 0.524, σ = 3.549)
(μ = 3.540, σ = 2.089)
(μ = 3.727, σ = 2.483)
(μ = 3.463, σ = 2.582)
(μ = 5.052, σ = 2.919)
(μ = 4.813, σ = 1.818)
(μ = 4.015, σ = 1.587)
(μ = 5.244, σ = 3.949)
(μ = 1.456, σ = 5.624)
(μ = 4.045, σ = 2.010)
m = @model begin
μ ~ Normal(0, 5)
σ ~ HalfCauchy(3)
x ~ Normal(μ, σ) |> iid
end
m = @model begin
μ ~ Normal(0, 5)
σ ~ HalfCauchy(3)
x ~ Normal(μ, σ) |> iid
end
julia> m(:x)
m = @model x begin
μ ~ Normal(0, 5)
σ ~ HalfCauchy(3)
x ~ Normal(μ, σ) |> iid
end
julia> m(x = [1.0, 1.1, 1.5])
@model begin
x = [1.0, 1.1, 1.5]
μ ~ Normal(0, 5)
σ ~ HalfCauchy(3)
x ~ Normal(μ, σ) |> iid
end
Observe values statically
or dynamically
m1 = @model begin
...
end
mix = @model x,components begin
α = ones(length(components))
weights ~ Dirichlet(α)
x ~ MixtureModel(components,weights) |> iid
end
julia> mix(components=[m1, m2])
@model x begin
components = [m1, m2]
K = length(components)
weights ~ Dirichlet(ones(K))
x ~ MixtureModel(components, weights) |> iid
end
m2 = @model begin
...
end
function logdensity(model)
body = postwalk(model.body) do x
if @capture(x, v_ ~ dist_)
assignment = ifelse(
v ∈ parameters(model),
:($v = par.$v),
:($v = data.$v)
)
quote
$assignment
ℓ += logpdf($dist, $v)
end
else x
end
end
return quote
function(par, data)
ℓ = 0.0
$body
return ℓ
end
end
end
julia> m(:x)
@model x begin
μ ~ Normal(0, 5)
σ ~ HalfCauchy(3)
x ~ Normal(μ, σ) |> iid
end
julia> logdensity(m(:x))
:(function (par, data)
ℓ = 0.0
μ = par.μ
ℓ += logpdf(Normal(0, 5), μ)
σ = par.σ
ℓ += logpdf(HalfCauchy(3), σ)
x = data.x
ℓ += logpdf(Normal(μ, σ) |> iid, x)
return ℓ
end)
julia> lda
@model (α, η, K, V, N) begin
M = length(N)
β ~ Dirichlet(repeat([η], V)) |> iid(K)
θ ~ Dirichlet(repeat([α], K)) |> iid(M)
z ~ For(1:M) do m
Categorical(θ[m]) |> iid(N[m])
end
w ~ For(1:M) do m
For(1:N[m]) do n
Categorical(β[(z[m])[n]])
end
end
end
julia> dependencies(lda)
10-element Array{Pair{Array{Symbol,1},Symbol},1}:
[] => :α
[] => :η
[] => :K
[] => :V
[] => :N
[:N] => :M
[:η, :V, :K] => :β
[:α, :K, :M] => :θ
[:M, :θ, :N] => :z
[:M, :N, :β, :z] => :w
Blei, Ng, & Jordan (2003). Latent Dirichlet Allocation. JMLR, 3(4–5), 993–1022.
logo by James Fairbanks, on Julia Discourse site