Skip to content

Commit

Permalink
better init_params
Browse files Browse the repository at this point in the history
  • Loading branch information
JaimeRZP committed Jul 3, 2023
1 parent 71aac85 commit 4f66880
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/contrib/inference/abstractmcmc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function AbstractMCMC.step(
rng::Random.AbstractRNG,
model::DynamicPPL.Model,
sampler_wrapper::Sampler{<:ExternalSampler};
init_params=nothing,
kwargs...
)
sampler = sampler_wrapper.alg.sampler
Expand All @@ -58,6 +59,11 @@ function AbstractMCMC.step(
# Link the varinfo.
f = setvarinfo(f, DynamicPPL.link!!(getvarinfo(f), model))

# Make init_params
if init_params === nothing
init_params = 4 .* rand(rng, LogDensityProblems.dimension(f)) .- 2

Check warning on line 64 in src/contrib/inference/abstractmcmc.jl

View check run for this annotation

Codecov / codecov/patch

src/contrib/inference/abstractmcmc.jl#L63-L64

Added lines #L63 - L64 were not covered by tests
end

# Then just call `AdvancedHMC.step` with the right arguments.
transition_inner, state_inner = AbstractMCMC.step(
rng, AbstractMCMC.LogDensityModel(f), sampler; kwargs...
Expand Down

0 comments on commit 4f66880

Please sign in to comment.