-
Notifications
You must be signed in to change notification settings - Fork 15
Add auto-marginalization implementation to the main package #385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
JuliaBUGS.jl documentation for PR #385 is available at: |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #385 +/- ##
==========================================
+ Coverage 83.26% 83.64% +0.37%
==========================================
Files 31 31
Lines 3759 4066 +307
==========================================
+ Hits 3130 3401 +271
- Misses 629 665 +36 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
JuliaFormatter
[JuliaFormatter] reported by reviewdog 🐶
println("[FrontierCacheTest] Computing minimal keys (states-first)..."); flush(stdout) |
[JuliaFormatter] reported by reviewdog 🐶
println("[FrontierCacheTest] Evaluating logp with interleaved order..."); flush(stdout) |
[JuliaFormatter] reported by reviewdog 🐶
println("[FrontierCacheTest] Evaluating logp with states-first order..."); flush(stdout) |
[JuliaFormatter] reported by reviewdog 🐶
println("[FrontierCacheTest] Done evaluations, comparing..."); flush(stdout) |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Benchmark results on macOS (aarch64)BridgeStan not found at location specified by $BRIDGESTAN environment variable, downloading version 2.6.2 to /Users/runner/.bridgestan/bridgestan-2.6.2 Stan results:
JuliaBUGS Mooncake results:
Benchmark results on Ubuntu (x64)BridgeStan not found at location specified by $BRIDGESTAN environment variable, downloading version 2.6.2 to /home/runner/.bridgestan/bridgestan-2.6.2 Stan results:
JuliaBUGS Mooncake results:
|
Pull Request Test Coverage Report for Build 17946143376Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
JuliaFormatter
[JuliaFormatter] reported by reviewdog 🐶
logp, logp_ref = run_case(K=K, T=T, seed=seed) |
[JuliaFormatter] reported by reviewdog 🐶
eps = try parse(Float64, get(ENV, "AGC_EPS", "1e-5")) catch; 1e-5 end |
[JuliaFormatter] reported by reviewdog 🐶
sim = simulate_hmm(rng, T, K; init_probs=init_probs, transition=transition, means=means_true, sigmas=sigmas_true) |
[JuliaFormatter] reported by reviewdog 🐶
mu_prior_mean, mu_prior_std, logsigma_prior_mean, logsigma_prior_std = priors_from_truth(means_true, sigmas_true) |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/scripts/hmm_gradient_check.jl
Lines 114 to 122 in 2d7a51b
T = T, | |
K = K, | |
y = sim.y, | |
init_probs = init_probs, | |
transition = transition, | |
mu_prior_mean = mu_prior_mean, | |
mu_prior_std = mu_prior_std, | |
logsigma_prior_mean = logsigma_prior_mean, | |
logsigma_prior_std = logsigma_prior_std, |
[JuliaFormatter] reported by reviewdog 🐶
logp, max_abs_diff, max_rel_diff = run_case(seed, K, T; ϵ=eps, verbose=(verbose && is_single)) |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/scripts/hmm_marginal_logp.jl
Lines 69 to 70 in 2d7a51b
rng = MersenneTwister(get(ENV, "AM_SEED", "1") |> x -> parse(Int, x)) | |
T = get(ENV, "AM_T", "50") |> x -> parse(Int, x) |
[JuliaFormatter] reported by reviewdog 🐶
sim = simulate_hmm(rng, T; init_probs=init_probs, transition=transition, means=means, sigmas=sigmas) |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/scripts/hmm_marginal_logp.jl
Lines 81 to 87 in 2d7a51b
T = T, | |
K = K, | |
y = sim.obs, | |
init_probs = init_probs, | |
transition = transition, | |
means = means, | |
sigmas = sigmas, |
[JuliaFormatter] reported by reviewdog 🐶
trials = try parse(Int, get(ENV, "AS_TRIALS", "5")) catch; 5 end |
[JuliaFormatter] reported by reviewdog 🐶
function simulate_hmm(rng::AbstractRNG, T::Int, K::Int; init_probs, transition, means, sigmas) |
[JuliaFormatter] reported by reviewdog 🐶
sim = simulate_hmm(rng, T, K; init_probs=init_probs, transition=transition, means=means, sigmas=sigmas) |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/scripts/hmm_scaling_bench.jl
Lines 101 to 107 in 2d7a51b
T = T, | |
K = K, | |
y = sim.obs, | |
init_probs = init_probs, | |
transition = transition, | |
means = means, | |
sigmas = sigmas, |
[JuliaFormatter] reported by reviewdog 🐶
mean_time, logp, max_f, mean_f, sum_f = bench_case(K=K, T=T, seed=seed, trials=trials) |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/scripts/hmt_order_comparison.jl
Lines 20 to 24 in 2d7a51b
B = try parse(Int, get(ENV, "AHMT_B", "2")) catch; 2 end | |
depth = try parse(Int, get(ENV, "AHMT_DEPTH", "8")) catch; 8 end | |
K = try parse(Int, get(ENV, "AHMT_K", "4")) catch; 4 end | |
seed = try parse(Int, get(ENV, "AHMT_SEED", "1")) catch; 1 end | |
trials = try parse(Int, get(ENV, "AHMT_TRIALS", "10")) catch; 10 end |
[JuliaFormatter] reported by reviewdog 🐶
cost_thresh = try parse(Float64, get(ENV, "AHMT_COST_THRESH", "1.0e8")) catch; 1.0e8 end |
[JuliaFormatter] reported by reviewdog 🐶
function simulate_hmt(rng::AbstractRNG, B::Int, depth::Int, K::Int; init_probs, transition, means, sigmas) |
[JuliaFormatter] reported by reviewdog 🐶
sim = simulate_hmt(rng, B, depth, K; init_probs=init_probs, transition=transition, means=means, sigmas=sigmas) |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/scripts/hmt_order_comparison.jl
Lines 91 to 100 in 2d7a51b
B = B, | |
depth = depth, | |
N = N, | |
K = K, | |
y = sim.y, | |
init_probs = init_probs, | |
transition = transition, | |
means = means, | |
sigmas = sigmas, | |
parent = parent, |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/scripts/hmt_order_comparison.jl
Lines 113 to 117 in 2d7a51b
"dfs" => () -> make_model_with_order(model, build_hmt_dfs_order(model; B_hint=B)), | |
"bfs" => () -> make_model_with_order(model, build_hmt_bfs_order(model)), | |
"random_dfs" => () -> make_model_with_order(model, build_hmt_dfs_order(model; B_hint=B, rng=MersenneTwister(seed+1), randomized=true)), | |
"min_fill" => () -> make_model_with_order(model, build_min_fill_order(model; rng=MersenneTwister(seed+2), num_restarts=3)), | |
"min_degree" => () -> make_model_with_order(model, build_min_degree_order(model; rng=MersenneTwister(seed+3), num_restarts=3)), |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/scripts/hmt_order_comparison.jl
Lines 138 to 140 in 2d7a51b
) ( | |
isnan(logp) ? "NA" : @sprintf("%.12f", logp) | |
) |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Lines 47 to 48 in 2d7a51b
i = try parse(Int, s[3:end-1]) catch; -1 end | |
if i > 0; z_idxs[i] = j; else; push!(other, j); end |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Lines 50 to 51 in 2d7a51b
i = try parse(Int, s[3:end-1]) catch; -1 end | |
if i > 0; y_idxs[i] = j; else; push!(other, j); end |
[JuliaFormatter] reported by reviewdog 🐶
if yi != 0; push!(order, yi); end |
[JuliaFormatter] reported by reviewdog 🐶
inner = replace(s[3:end-1], " " => "") |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Lines 96 to 97 in 2d7a51b
c = try parse(Int, parts[1]) catch; -1 end | |
t = try parse(Int, parts[2]) catch; -1 end |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 134 in 2d7a51b
inner = replace(s[3:end-1], " " => "") |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Lines 137 to 138 in 2d7a51b
c = try parse(Int, parts[1]) catch; -1 end | |
t = try parse(Int, parts[2]) catch; -1 end |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 185 in 2d7a51b
if placed[i]; return; end |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 198 in 2d7a51b
ps = [p for p in st_parents[j] if gd.is_discrete_finite_vals[p] && !gd.is_observed_vals[p]] |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 274 in 2d7a51b
return |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 309 in 2d7a51b
gd2 = JModel.GraphEvaluationData{typeof(gd.node_function_vals),typeof(gd.loop_vars_vals)}( |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 340 in 2d7a51b
i = try parse(Int, s[3:end-1]) catch; -1 end |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 347 in 2d7a51b
i = try parse(Int, s[3:end-1]) catch; -1 end |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 384 in 2d7a51b
inner = replace(s[3:end-1], " " => "") |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Lines 387 to 388 in 2d7a51b
c = try parse(Int, parts[1]) catch; -1 end | |
t = try parse(Int, parts[2]) catch; -1 end |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 396 in 2d7a51b
i = try parse(Int, s[3:end-1]) catch; -1 end |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 441 in 2d7a51b
i = try parse(Int, s[3:end-1]) catch; -1 end |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 503 in 2d7a51b
i = try parse(Int, s[3:end-1]) catch; -1 end |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 560 in 2d7a51b
if gd.is_discrete_finite_vals[i] && !gd.is_observed_vals[i] && gd.is_stochastic_vals[i] |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 575 in 2d7a51b
for k in (i+1):length(disc_parents) |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 598 in 2d7a51b
for j in (i+1):length(neighbors_vec) |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 619 in 2d7a51b
for j in (i+1):length(neighbors_vec) |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 683 in 2d7a51b
test_model = make_model_with_order(model, build_eval_order_from_discrete_order(model, order)) |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 758 in 2d7a51b
test_model = make_model_with_order(model, build_eval_order_from_discrete_order(model, order)) |
[JuliaFormatter] reported by reviewdog 🐶
@warn "Failed to precompute auto-marginalization caches; falling back to graph evaluation" exception=(err, catch_backtrace()) |
[JuliaFormatter] reported by reviewdog 🐶
branch_loglikelihoods = Vector{typeof(lik_val)}(undef, length(possible_values)) |
[JuliaFormatter] reported by reviewdog 🐶
log_joint_total = LogExpFunctions.logsumexp(total_logpriors .+ branch_loglikelihoods) |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/test/model/auto_marginalization.jl
Lines 723 to 729 in 2d7a51b
data = ( | |
K=2, | |
w=[0.3, 0.7], | |
delta=[0.0, 2.0], | |
sigma=1.0, | |
y=1.5, | |
) |
C = try parse(Int, get(ENV, "AFH_C", "2")) catch; 2 end | ||
K = try parse(Int, get(ENV, "AFH_K", "4")) catch; 4 end | ||
T = try parse(Int, get(ENV, "AFH_T", "100")) catch; 100 end | ||
seed = try parse(Int, get(ENV, "AFH_SEED", "1")) catch; 1 end | ||
trials = try parse(Int, get(ENV, "AFH_TRIALS", "10")) catch; 10 end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
C = try parse(Int, get(ENV, "AFH_C", "2")) catch; 2 end | |
K = try parse(Int, get(ENV, "AFH_K", "4")) catch; 4 end | |
T = try parse(Int, get(ENV, "AFH_T", "100")) catch; 100 end | |
seed = try parse(Int, get(ENV, "AFH_SEED", "1")) catch; 1 end | |
trials = try parse(Int, get(ENV, "AFH_TRIALS", "10")) catch; 10 end | |
C = try | |
parse(Int, get(ENV, "AFH_C", "2")) | |
catch | |
; 2 | |
end | |
K = try | |
parse(Int, get(ENV, "AFH_K", "4")) | |
catch | |
; 4 | |
end | |
T = try | |
parse(Int, get(ENV, "AFH_T", "100")) | |
catch | |
; 100 | |
end | |
seed = try | |
parse(Int, get(ENV, "AFH_SEED", "1")) | |
catch | |
; 1 | |
end | |
trials = try | |
parse(Int, get(ENV, "AFH_TRIALS", "10")) | |
catch | |
; 10 | |
end |
seed = try parse(Int, get(ENV, "AFH_SEED", "1")) catch; 1 end | ||
trials = try parse(Int, get(ENV, "AFH_TRIALS", "10")) catch; 10 end | ||
mode = lowercase(get(ENV, "AFH_MODE", "frontier")) # frontier | timed | ||
cost_thresh = try parse(Float64, get(ENV, "AFH_COST_THRESH", "1.0e8")) catch; 1.0e8 end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
cost_thresh = try parse(Float64, get(ENV, "AFH_COST_THRESH", "1.0e8")) catch; 1.0e8 end | |
cost_thresh = try | |
parse(Float64, get(ENV, "AFH_COST_THRESH", "1.0e8")) | |
catch | |
; 1.0e8 | |
end |
return init_probs, transition, mu, sigma_y | ||
end | ||
|
||
function simulate_fhmm(rng::AbstractRNG, C::Int, K::Int, T::Int; init_probs, transition, mu, sigma_y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
function simulate_fhmm(rng::AbstractRNG, C::Int, K::Int, T::Int; init_probs, transition, mu, sigma_y) | |
function simulate_fhmm( | |
rng::AbstractRNG, C::Int, K::Int, T::Int; init_probs, transition, mu, sigma_y | |
) |
# Simulate data | ||
rng = MersenneTwister(seed) | ||
init_probs, transition, mu, sigma_y = default_fhmm_params(C, K) | ||
sim = simulate_fhmm(rng, C, K, T; init_probs=init_probs, transition=transition, mu=mu, sigma_y=sigma_y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
sim = simulate_fhmm(rng, C, K, T; init_probs=init_probs, transition=transition, mu=mu, sigma_y=sigma_y) | |
sim = simulate_fhmm( | |
rng, C, K, T; init_probs=init_probs, transition=transition, mu=mu, sigma_y=sigma_y | |
) |
C = C, | ||
K = K, | ||
T = T, | ||
y = sim.y, | ||
init_probs = init_probs, | ||
transition = transition, | ||
mu = mu, | ||
sigma_y = sigma_y, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
C = C, | |
K = K, | |
T = T, | |
y = sim.y, | |
init_probs = init_probs, | |
transition = transition, | |
mu = mu, | |
sigma_y = sigma_y, | |
C=C, | |
K=K, | |
T=T, | |
y=sim.y, | |
init_probs=init_probs, | |
transition=transition, | |
mu=mu, | |
sigma_y=sigma_y, |
T = T, | ||
K = K, | ||
y = y, | ||
alpha = α, | ||
gamma = γ, | ||
kappa = κ, | ||
mu0 = m0, | ||
mu0_std = s0, | ||
logsigma0 = ℓ0, | ||
logsigma0_std = τ0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
T = T, | |
K = K, | |
y = y, | |
alpha = α, | |
gamma = γ, | |
kappa = κ, | |
mu0 = m0, | |
mu0_std = s0, | |
logsigma0 = ℓ0, | |
logsigma0_std = τ0, | |
T=T, | |
K=K, | |
y=y, | |
alpha=α, | |
gamma=γ, | |
kappa=κ, | |
mu0=m0, | |
mu0_std=s0, | |
logsigma0=ℓ0, | |
logsigma0_std=τ0, |
end | ||
|
||
for seed in seeds, K in Ks, T in Ts | ||
logp, max_abs_diff, max_rel_diff = run_case(seed, K, T; α=alpha, γ=gamma, κ=kappa, ϵ=eps, verbose=(verbose && is_single)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
logp, max_abs_diff, max_rel_diff = run_case(seed, K, T; α=alpha, γ=gamma, κ=kappa, ϵ=eps, verbose=(verbose && is_single)) | |
logp, max_abs_diff, max_rel_diff = run_case( | |
seed, K, T; α=alpha, γ=gamma, κ=kappa, ϵ=eps, verbose=(verbose && is_single) | |
) |
using LogDensityProblems | ||
using LogExpFunctions: logsumexp | ||
|
||
function simulate_hmm(rng::AbstractRNG, T::Int, K::Int; init_probs, transition, means, sigmas) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
function simulate_hmm(rng::AbstractRNG, T::Int, K::Int; init_probs, transition, means, sigmas) | |
function simulate_hmm( | |
rng::AbstractRNG, T::Int, K::Int; init_probs, transition, means, sigmas | |
) |
function run_case(; K::Int, T::Int, seed::Int) | ||
rng = MersenneTwister(seed) | ||
init_probs, transition, means, sigmas = default_params(K) | ||
sim = simulate_hmm(rng, T, K; init_probs=init_probs, transition=transition, means=means, sigmas=sigmas) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
sim = simulate_hmm(rng, T, K; init_probs=init_probs, transition=transition, means=means, sigmas=sigmas) | |
sim = simulate_hmm( | |
rng, T, K; init_probs=init_probs, transition=transition, means=means, sigmas=sigmas | |
) |
T = T, | ||
K = K, | ||
y = sim.obs, | ||
init_probs = init_probs, | ||
transition = transition, | ||
means = means, | ||
sigmas = sigmas, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
T = T, | |
K = K, | |
y = sim.obs, | |
init_probs = init_probs, | |
transition = transition, | |
means = means, | |
sigmas = sigmas, | |
T=T, | |
K=K, | |
y=sim.obs, | |
init_probs=init_probs, | |
transition=transition, | |
means=means, | |
sigmas=sigmas, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
JuliaFormatter
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 274 in aec0159
return |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 309 in aec0159
gd2 = JModel.GraphEvaluationData{typeof(gd.node_function_vals),typeof(gd.loop_vars_vals)}( |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 340 in aec0159
i = try parse(Int, s[3:end-1]) catch; -1 end |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 347 in aec0159
i = try parse(Int, s[3:end-1]) catch; -1 end |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 384 in aec0159
inner = replace(s[3:end-1], " " => "") |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Lines 387 to 388 in aec0159
c = try parse(Int, parts[1]) catch; -1 end | |
t = try parse(Int, parts[2]) catch; -1 end |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 396 in aec0159
i = try parse(Int, s[3:end-1]) catch; -1 end |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 441 in aec0159
i = try parse(Int, s[3:end-1]) catch; -1 end |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 503 in aec0159
i = try parse(Int, s[3:end-1]) catch; -1 end |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 560 in aec0159
if gd.is_discrete_finite_vals[i] && !gd.is_observed_vals[i] && gd.is_stochastic_vals[i] |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 575 in aec0159
for k in (i+1):length(disc_parents) |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 598 in aec0159
for j in (i+1):length(neighbors_vec) |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 619 in aec0159
for j in (i+1):length(neighbors_vec) |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 683 in aec0159
test_model = make_model_with_order(model, build_eval_order_from_discrete_order(model, order)) |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/experiments/utils.jl
Line 758 in aec0159
test_model = make_model_with_order(model, build_eval_order_from_discrete_order(model, order)) |
[JuliaFormatter] reported by reviewdog 🐶
@warn "Failed to precompute auto-marginalization caches; falling back to graph evaluation" exception=(err, catch_backtrace()) |
[JuliaFormatter] reported by reviewdog 🐶
branch_loglikelihoods = Vector{typeof(lik_val)}(undef, length(possible_values)) |
[JuliaFormatter] reported by reviewdog 🐶
log_joint_total = LogExpFunctions.logsumexp(total_logpriors .+ branch_loglikelihoods) |
[JuliaFormatter] reported by reviewdog 🐶
JuliaBUGS.jl/JuliaBUGS/test/model/auto_marginalization.jl
Lines 723 to 729 in aec0159
data = ( | |
K=2, | |
w=[0.3, 0.7], | |
delta=[0.0, 2.0], | |
sigma=1.0, | |
y=1.5, | |
) |
@printf "# HMM correctness sweep\n" | ||
@printf "# seed,K,T,logp_autmarg,logp_forward,diff\n" | ||
for seed in seed_vals, K in Ks, T in Ts | ||
logp, logp_ref = run_case(K=K, T=T, seed=seed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
logp, logp_ref = run_case(K=K, T=T, seed=seed) | |
logp, logp_ref = run_case(; K=K, T=T, seed=seed) |
isempty(xs) ? [50] : xs | ||
end | ||
|
||
eps = try parse(Float64, get(ENV, "AGC_EPS", "1e-5")) catch; 1e-5 end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
eps = try parse(Float64, get(ENV, "AGC_EPS", "1e-5")) catch; 1e-5 end | |
eps = try | |
parse(Float64, get(ENV, "AGC_EPS", "1e-5")) | |
catch | |
; 1e-5 | |
end |
transition[k, k] = diag | ||
end | ||
means_true, sigmas_true = default_hmm_params(K) | ||
sim = simulate_hmm(rng, T, K; init_probs=init_probs, transition=transition, means=means_true, sigmas=sigmas_true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
sim = simulate_hmm(rng, T, K; init_probs=init_probs, transition=transition, means=means_true, sigmas=sigmas_true) | |
sim = simulate_hmm( | |
rng, | |
T, | |
K; | |
init_probs=init_probs, | |
transition=transition, | |
means=means_true, | |
sigmas=sigmas_true, | |
) |
means_true, sigmas_true = default_hmm_params(K) | ||
sim = simulate_hmm(rng, T, K; init_probs=init_probs, transition=transition, means=means_true, sigmas=sigmas_true) | ||
|
||
mu_prior_mean, mu_prior_std, logsigma_prior_mean, logsigma_prior_std = priors_from_truth(means_true, sigmas_true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
mu_prior_mean, mu_prior_std, logsigma_prior_mean, logsigma_prior_std = priors_from_truth(means_true, sigmas_true) | |
mu_prior_mean, mu_prior_std, logsigma_prior_mean, logsigma_prior_std = priors_from_truth( | |
means_true, sigmas_true | |
) |
T = T, | ||
K = K, | ||
y = sim.y, | ||
init_probs = init_probs, | ||
transition = transition, | ||
mu_prior_mean = mu_prior_mean, | ||
mu_prior_std = mu_prior_std, | ||
logsigma_prior_mean = logsigma_prior_mean, | ||
logsigma_prior_std = logsigma_prior_std, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
T = T, | |
K = K, | |
y = sim.y, | |
init_probs = init_probs, | |
transition = transition, | |
mu_prior_mean = mu_prior_mean, | |
mu_prior_std = mu_prior_std, | |
logsigma_prior_mean = logsigma_prior_mean, | |
logsigma_prior_std = logsigma_prior_std, | |
T=T, | |
K=K, | |
y=sim.y, | |
init_probs=init_probs, | |
transition=transition, | |
mu_prior_mean=mu_prior_mean, | |
mu_prior_std=mu_prior_std, | |
logsigma_prior_mean=logsigma_prior_mean, | |
logsigma_prior_std=logsigma_prior_std, |
c = try parse(Int, parts[1]) catch; -1 end | ||
t = try parse(Int, parts[2]) catch; -1 end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
c = try parse(Int, parts[1]) catch; -1 end | |
t = try parse(Int, parts[2]) catch; -1 end | |
c = try | |
parse(Int, parts[1]) | |
catch | |
; -1 | |
end | |
t = try | |
parse(Int, parts[2]) | |
catch | |
; -1 | |
end |
for (j, vn) in enumerate(gd.sorted_nodes) | ||
s = string(vn) | ||
if startswith(s, "z[") | ||
inner = replace(s[3:end-1], " " => "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
inner = replace(s[3:end-1], " " => "") | |
inner = replace(s[3:(end - 1)], " " => "") |
c = try parse(Int, parts[1]) catch; -1 end | ||
t = try parse(Int, parts[2]) catch; -1 end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
c = try parse(Int, parts[1]) catch; -1 end | |
t = try parse(Int, parts[2]) catch; -1 end | |
c = try | |
parse(Int, parts[1]) | |
catch | |
; -1 | |
end | |
t = try | |
parse(Int, parts[2]) | |
catch | |
; -1 | |
end |
|
||
function place_with_dependencies(vn) | ||
i = pos[vn] | ||
if placed[i]; return; end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
if placed[i]; return; end | |
if placed[i] | |
; | |
return nothing; | |
end |
obs_nodes = [i for i in 1:n if gd.is_stochastic_vals[i] && gd.is_observed_vals[i]] | ||
obs_disc_parents = Dict{Int,Vector{Int}}() | ||
for j in obs_nodes | ||
ps = [p for p in st_parents[j] if gd.is_discrete_finite_vals[p] && !gd.is_observed_vals[p]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
ps = [p for p in st_parents[j] if gd.is_discrete_finite_vals[p] && !gd.is_observed_vals[p]] | |
ps = [ | |
p for | |
p in st_parents[j] if gd.is_discrete_finite_vals[p] && !gd.is_observed_vals[p] | |
] |
No description provided.