Skip to content

Issue: Cannot init variables via Vector{Vector{}} indexing. #284

Description

@bvdmitri

Discussed in https://github.com/orgs/ReactiveBayes/discussions/490

Originally posted by ofSingularMind August 13, 2025
I had a data variable ω for which I needed to process the components of in separate nodes. I formatted ω as a Vector{Vector{}} and passed it to the model in data = () field. I defined the portion of my model specific to ω as below.

for i in 1:size(ω, 1)
  ω[i][1] ~ UniSGP_AMF_Grad(x[i], v, w, θ, 1) 
  ω[i][2] ~ UniSGP_AMF_Grad(x[i], v, w, θ, 2) 
  ω[i][3] ~ UniSGP_AMF_Grad(x[i], v, w, θ, 3) 
end

Unfortunately, this did not work and lead to node variables not being updated. The solution was to format data object ω as a matrix and to utilize row, column indexing as below.

for i in 1:size(ω, 1)
  ω[i, 1] ~ GenericNode(x[i], v, w, θ, 1) 
  ω[i, 2] ~ GenericNode(x[i], v, w, θ, 2) 
  ω[i, 3] ~ GenericNode(x[i], v, w, θ, 3) 
end

This works fine, but maybe we should allow for Vector{Vector{}} formatting of data variables that need to be split up.

Thanks! Alex

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions