ReactiveBayes / GraphPPL.jl

DSL for probabilistic models specification and probabilistic programming.
MIT License
31 stars 5 forks source link

Inference using a DataArray #23

Open Dhuige opened 1 year ago

Dhuige commented 1 year ago

It might be nice to infer data using an array. Slicing the array into a vector in the model able to read it out

By which I mean that one would be able to use an array given the following:

image

albertpod commented 1 year ago

Hi @Dhuige,

Thanks for trying out RxInfer.jl. Can you be more specific about the nature of the issue? The model you've provided is incomplete and has unused variables, e.g. y and tau

In order to create a multivariate input, you should use the following datavar specification.

Data_Array = datavar(Vector{Float64}, N)

You can't use dot with a vector of datavars of type Float64. It must be instead a single datavar of type Vector{Float64}, e.g.

Data_Array_Univariate = datavar(Float64, N)
Data_Array_Multivariate = datavar(Vector{Float64}, N)
for i in 1:N
    Data_Array_Univariate[i] ~ dot(Data_Array_Multivariate[i], theta) + epsilon
end

We will be happy to help further if you provide more details on what you are trying to achieve with this model.

Dhuige commented 1 year ago

Thank you for the improvement on my code used, what I am trying to say is that it would be nice if one could use 1 Array as input and output. In this example, this would imply that a slice of the multivariate is treated as Data_Array_Univariate.

in other words: Data_Array_Univariate = datavar(Float64, N) Data_Array_Multivariate = datavar(Vector{Float64}, N) for i in 1:N Data_Array_Multivariate[:,1][i] ~ dot(Data_Array_Multivariate[i], theta) + epsilon end

Preferably, the dot product would also work if the Data_Array_Multivariate is sliced in an array (since it will make mathematical sense, thus convenient to use).

albertpod commented 1 year ago

I see @Dhuige. Thanks for raising the issue. This type of model definition isn't supported yet.

bvdmitri commented 1 year ago

@albertpod @wouterwln @Dhuige We may consider this improvement in the next iteration of the GraphPPL.jl, should be doable imo

bvdmitri commented 11 months ago

ping @wouterwln

wouterwln commented 2 months ago

I think this is possible in RxInfer 3.0 onward, right?

bvdmitri commented 2 months ago

I'm not entirely sure, better to add a test for it