Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling loops in variational message passing algorithm. #98

Open
albertpod opened this issue Jul 8, 2020 · 0 comments
Open

Handling loops in variational message passing algorithm. #98

albertpod opened this issue Jul 8, 2020 · 0 comments

Comments

@albertpod
Copy link
Collaborator

I am trying to build the inference algorithm in the coupled random walk model:

Screenshot 2020-07-08 at 12 54 57

We assume the following factorization: q = PosteriorFactorization(x_0, x, γ_x, w_0, w, γ_w)
However, ForneyLab throws an error when calling variationalAlgorithm(q, free_energy=false) due to the loop (green edges):
ArgumentError: The input graph contains a loop around Interface 2 (m) of GaussianMeanPrecision gaussianmeanprecision_3

In my opinion, if the loop occurs, ForneyLab should still be able to build the algorithm, but the user would have to provide a schedule.

Here is the code snippet:

using ForneyLab

n_samples = 2

fg = FactorGraph()

# Hidden process model
@RV x_0 ~ GaussianMeanVariance(placeholder(:m_x_0),
                               placeholder(:v_x_0))

@RV γ_x ~ ForneyLab.Gamma(placeholder(:a_x), placeholder(:b_x))

# Noise model
@RV w_0 ~ GaussianMeanVariance(placeholder(:m_w_0),
                               placeholder(:v_w_0))

@RV γ_w ~ ForneyLab.Gamma(placeholder(:a_w), placeholder(:b_w))

# Transition and observation models
x = Vector{Variable}(undef, n_samples)
w = Vector{Variable}(undef, n_samples)
y = Vector{Variable}(undef, n_samples)

x_i_min = x_0
w_i_min = w_0
for i in 1:n_samples
    global x_i_min, w_i_min
    @RV x[i] ~ GaussianMeanPrecision(x_i_min, γ_x)
    @RV w[i] ~ GaussianMeanPrecision(w_i_min, γ_w)
    @RV y[i] = x[i] + w[i]

    # Data placeholder
    placeholder(y[i], :y, index=i)

    # Reset state for next step
    x_i_min = x[i]
    w_i_min = w[i]
end

q = PosteriorFactorization(x_0, x, γ_x, w_0, w, γ_w, ids=[:X0 :X :ΓX :W0 :W :ΓW])
algo = variationalAlgorithm(q, free_energy=false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant