You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a model where an error occurs depending how I define the Naive Mean Field in the constrains:
it works if:
q(y, yprior, s, θ) = q(y)q(yprior)q(s)q(θ)
it doesn't work if:
q(y, yprior, s, θ) = MeanField()
`# Atomic Filter @model function prob_lpf_switch(y, μx0, vx0, p∞, θ)
m = (0.0, 0.0)
yprior ~ Normal(mean = μx0, variance = vx0)
s ~ NormalMixture(switch = θ, m = m, p = p∞)
y := yprior + s
end
@model function prob_xnr_encap(y, π, μx0s, vx0s, μx0n, vx0n, vy, ps∞, pn∞)
θ ~ Bernoulli(π)
sp ~ prob_lpf_switch(μx0 = μx0s, vx0 = vx0s, p∞ = ps∞, θ = θ,)
np ~ prob_lpf_switch(μx0 = μx0n, vx0 = vx0n, p∞ = pn∞, θ = θ,)
g := sp - np
g ~ Normal(m = 0.0, v = 1e10)
y ~ Normal(m = sp, v = vy)
y ~ Normal(m = np, v = vy)
end
function run_inference(data, π, vy, ps∞, pn∞)
autoupdates = @autoupdates begin
μx0s, vx0s = mean_var(q(sp))
μx0n, vx0n = mean_var(q(np))
end
initialization = @initialization begin
q(g) = vague(NormalMeanVariance)
q(np) = vague(NormalMeanVariance)
q(sp) = vague(NormalMeanVariance)
for init in prob_lpf_switch
q(y) = vague(NormalMeanVariance)
q(s) = vague(NormalMeanVariance)
end
end
constraints = @constraints begin
for q in prob_lpf_switch
q(y, yprior, s, θ) = MeanField()#q(y)q(yprior)q(s)q(θ)
end
q(sp, np, g) = MeanField()
end
rxengine = infer(
model = prob_xnr_encap(vy = vy, ps∞ = ps∞, pn∞ = pn∞),
autoupdates = autoupdates,
data = (y = data, π = π),
initialization = initialization,
constraints = constraints,
free_energy = false,
showprogress = true,
keephistory = 8000,
historyvars = (
sp = KeepLast(),
np = KeepLast(),
g = KeepLast(),
),
returnvars = (:sp, :np, :g),
autostart = true,
)
return rxengine
end
`
The text was updated successfully, but these errors were encountered:
I have a model where an error occurs depending how I define the Naive Mean Field in the constrains:
it works if:
q(y, yprior, s, θ) = q(y)q(yprior)q(s)q(θ)
it doesn't work if:
q(y, yprior, s, θ) = MeanField()
`# Atomic Filter
@model function prob_lpf_switch(y, μx0, vx0, p∞, θ)
m = (0.0, 0.0)
yprior ~ Normal(mean = μx0, variance = vx0)
s ~ NormalMixture(switch = θ, m = m, p = p∞)
y := yprior + s
end
`
The text was updated successfully, but these errors were encountered: