Hello. I’m trying to extend one of the examples in RxInfer but hitting a wall.
I’m working starting from the Gaussian Linear Dynamical System example.
In particular I’m trying to generalise it so that we don’t assume to know the transition matrix A a priori. In the example A is passed as an input to the model function, and then converted to a constantvar
to be used in the model. I would like it to be given a prior in the model, and then inferred together with the remaining of the parameters.
I tried a couple of things, but I can’t make it work. A minimum reproducible example is consist in redefining model and inference as follows:
@model function rotate_ssm(n, x0, B, Q, P)
# We create constvar references for better efficiency
cB = constvar(B)
cQ = constvar(Q)
cP = constvar(P)
# `x` is a sequence of hidden states
x = randomvar(n)
# THIS IS WHERE I DIVERGE FROM EXAMPLE:
A = randomvar(2,2)
# `y` is a sequence of "clamped" observations
y = datavar(Vector{Float64}, n)
x_prior ~ MvNormalMeanCovariance(mean(x0), cov(x0))
x_prev = x_prior
α ~ Uniform(0.0,3.0)
β ~ Uniform(0.0,3.0)
A .~ Gamma(α,β)
for i in 1:n
x[i] ~ MvNormalMeanCovariance(A*x_prev, cQ)
y[i] ~ MvNormalMeanCovariance(cB * x[i], cP)
x_prev = x[i]
end
end
result = inference(
model = rotate_ssm(length(y), x0, B, Q, P),
data = (y = y,),
free_energy = true
)
When I try to run it, I get the following error:
ERROR: MethodError: no method matching make_node(::typeof(*), ::FactorNodeCreationOptions{FullFactorisation, Nothing, Nothing}, ::RandomVariable, ::Matrix{RandomVariable}, ::RandomVariable)