-
Notifications
You must be signed in to change notification settings - Fork 226
Ah/gibbs closed form cond #2597
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: main
Are you sure you want to change the base?
Conversation
::ExternalSampler{<:Any,<:Any,Unconstrained} | ||
) where {Unconstrained} = Unconstrained | ||
) where {Unconstrained} | ||
Unconstrained |
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 v1.0.62] reported by reviewdog 🐶
Unconstrained | |
return Unconstrained |
|
||
# Add wrap_in_sampler method for analytical GibbsConditional | ||
function wrap_in_sampler(gc::GibbsConditional) | ||
is_analytical_conditional(gc) ? gc : wrap_in_sampler(gc.sampler) |
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 v1.0.62] reported by reviewdog 🐶
is_analytical_conditional(gc) ? gc : wrap_in_sampler(gc.sampler) | |
return is_analytical_conditional(gc) ? gc : wrap_in_sampler(gc.sampler) |
unwrap_sampler(sampler::DynamicPPL.Sampler{<:AlgWrapper}) = DynamicPPL.Sampler( | ||
sampler.alg.inner | ||
) |
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 v1.0.62] reported by reviewdog 🐶
unwrap_sampler(sampler::DynamicPPL.Sampler{<:AlgWrapper}) = DynamicPPL.Sampler( | |
sampler.alg.inner | |
) | |
unwrap_sampler(sampler::DynamicPPL.Sampler{<:AlgWrapper}) = | |
DynamicPPL.Sampler(sampler.alg.inner) |
|
||
@model function simple_model() | ||
x ~ Normal(0, 1) | ||
y ~ Normal(x, 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 v1.0.62] reported by reviewdog 🐶
y ~ Normal(x, 1) | |
return y ~ Normal(x, 1) |
wo ~ | ||
MvNormal([0.0; 0; 0], [var_prior 0.0 0.0; 0.0 var_prior 0.0; 0.0 0.0 var_prior]) |
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 v1.0.62] reported by reviewdog 🐶
wo ~ | |
MvNormal([0.0; 0; 0], [var_prior 0.0 0.0; 0.0 var_prior 0.0; 0.0 0.0 var_prior]) | |
wo ~ MvNormal( | |
[0.0; 0; 0], [var_prior 0.0 0.0; 0.0 var_prior 0.0; 0.0 0.0 var_prior] | |
) |
DynamicPPL.setchildcontext(parent::OverrideContext, child) = OverrideContext( | ||
child, parent.logprior_weight, parent.loglikelihood_weight | ||
) |
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 v1.0.62] reported by reviewdog 🐶
DynamicPPL.setchildcontext(parent::OverrideContext, child) = OverrideContext( | |
child, parent.logprior_weight, parent.loglikelihood_weight | |
) | |
DynamicPPL.setchildcontext(parent::OverrideContext, child) = | |
OverrideContext(child, parent.logprior_weight, parent.loglikelihood_weight) |
check_success(result, check_retcode=true) = check_optimisation_result( | ||
result, true_value, true_logp, check_retcode | ||
) |
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 v1.0.62] reported by reviewdog 🐶
check_success(result, check_retcode=true) = check_optimisation_result( | |
result, true_value, true_logp, check_retcode | |
) | |
check_success(result, check_retcode=true) = | |
check_optimisation_result(result, true_value, true_logp, check_retcode) |
check_success(result, check_retcode=true) = check_optimisation_result( | ||
result, true_value, true_logp, check_retcode | ||
) |
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 v1.0.62] reported by reviewdog 🐶
check_success(result, check_retcode=true) = check_optimisation_result( | |
result, true_value, true_logp, check_retcode | |
) | |
check_success(result, check_retcode=true) = | |
check_optimisation_result(result, true_value, true_logp, check_retcode) |
check_success(result, check_retcode=true) = check_optimisation_result( | ||
result, true_value, true_logp, check_retcode | ||
) |
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 v1.0.62] reported by reviewdog 🐶
check_success(result, check_retcode=true) = check_optimisation_result( | |
result, true_value, true_logp, check_retcode | |
) | |
check_success(result, check_retcode=true) = | |
check_optimisation_result(result, true_value, true_logp, check_retcode) |
check_success(result, check_retcode=true) = check_optimisation_result( | ||
result, true_value, true_logp, check_retcode | ||
) |
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 v1.0.62] reported by reviewdog 🐶
check_success(result, check_retcode=true) = check_optimisation_result( | |
result, true_value, true_logp, check_retcode | |
) | |
check_success(result, check_retcode=true) = | |
check_optimisation_result(result, true_value, true_logp, check_retcode) |
Turing.jl documentation for PR #2597 is available at: |
Addresses -> #2547
Summary
This PR implements analytical conditional sampling support for the GibbsConditional sampler, restoring and enhancing functionality that was mentioned in the HISTORY.md. The new interface allows users to specify analytical conditional distributions as functions,
enabling more efficient Gibbs sampling when conditional distributions are known in closed form.
New Interface
GibbsConditional(sym, conditional)
Where:
Example Usage
Key Features
Implementation Details
Files Modified
New Types and Functions