One follow on question. If you could please explain why K is required in the function signature. Consider the two nearly-identical models (the only difference being whether K is given as a keyword argument.)
@model gmm(x, K=3) = begin
N = length(x)
μ ~ filldist(Normal(0,1), K)
w ~ Dirichlet(K, 1)
for ii in 1:N
x[ii] ~ MixtureModel(Normal, μ, w)
end
end
@model gmm2(x) = begin
K = 3
N = length(x)
μ = filldist(Normal(0,1), K)
w ~ Dirichlet(K, 1)
for ii in 1:N
x[ii] ~ MixtureModel(Normal, μ, w)
end
end
The following code executes successfully
model = gmm(Y)
advi = ADVI(10, 1000)
q = vi(model, advi)
Changing the first line above to model=gmm2(Y)
gives an error. How can this be when gmm(Y)
and gmm2(Y)
appear to be functionally equivalent?