You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I just tried to create a model in which I use the dot product to calculate \mu, the mean prediction. For clarification, i'll provide the code below:
@model function polynomial_regression(y, X, D, σ2)
# Prior distribution
β ~ MvNormalMeanCovariance(zeros(D + 1), 0.1 * diagm(ones(D + 1)))
# Define empty z
z = Vector{Vector{Float64}}(undef, length(X))
# Likelihood
for i in eachindex(X)
# Polynomial
z[i] = [X[i]^j for j in 0:D]
# prediction
μ = dot(β, z[i])
# μ = β ⋅ z
y[i] ~ NormalMeanVariance(μ, σ2[i])
end
end
Initialize variables
y = df[!,:y]
X = df[!,:x]
D = 3
σ2 = df[!,:σ2]
results = infer(
model = polynomial_regression(D = D, σ2 = σ2),
data = (y = y, X = X),
)
This code gives me the following error: StackOverflowError: Stacktrace: [1] dot(x::GraphPPL.NodeLabel, y::Float64) (repeats 79984 times) @ LinearAlgebra C:\Users\jespe.julia\juliaup\julia-1.10.7+0.x64.w64.mingw32\share\julia\stdlib\v1.10\LinearAlgebra\src\generic.jl:861
The error occurs in the dot function and it seems like it enters an infinite loop, creating a huge model or it tries to recursively resolve something adding TODO's in the stack until it overflows.
However, when I switch from: μ = dot(β, z[i]) y[i] ~ NormalMeanVariance(μ, σ2[i])
To: y[i] ~ NormalMeanVariance(dot(β, z[i]), σ2[i])
The function/model seems to work fine. Could this be an error in the package? Thanks for looking into it.
Kind regards,
Jesper
The text was updated successfully, but these errors were encountered:
Hi, I just tried to create a model in which I use the dot product to calculate \mu, the mean prediction. For clarification, i'll provide the code below:
@model function polynomial_regression(y, X, D, σ2)
end
Initialize variables
y = df[!,:y]
X = df[!,:x]
D = 3
σ2 = df[!,:σ2]
results = infer(
model = polynomial_regression(D = D, σ2 = σ2),
data = (y = y, X = X),
)
This code gives me the following error: StackOverflowError: Stacktrace: [1] dot(x::GraphPPL.NodeLabel, y::Float64) (repeats 79984 times) @ LinearAlgebra C:\Users\jespe.julia\juliaup\julia-1.10.7+0.x64.w64.mingw32\share\julia\stdlib\v1.10\LinearAlgebra\src\generic.jl:861
The error occurs in the dot function and it seems like it enters an infinite loop, creating a huge model or it tries to recursively resolve something adding TODO's in the stack until it overflows.
However, when I switch from:
μ = dot(β, z[i]) y[i] ~ NormalMeanVariance(μ, σ2[i])
To:
y[i] ~ NormalMeanVariance(dot(β, z[i]), σ2[i])
The function/model seems to work fine. Could this be an error in the package? Thanks for looking into it.
Kind regards,
Jesper
The text was updated successfully, but these errors were encountered: