Skip to content

Commit 335cd2a

Browse files
committed
more fixes for evaluate!!
1 parent 9cbb2e9 commit 335cd2a

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/mcmc/ess.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function AbstractMCMC.step(
4242

4343
# define previous sampler state
4444
# (do not use cache to avoid in-place sampling from prior)
45-
oldstate = EllipticalSliceSampling.ESSState(f, getlogp(vi), nothing)
45+
oldstate = EllipticalSliceSampling.ESSState(f, DynamicPPL.getloglikelihood(vi), nothing)
4646

4747
# compute next state
4848
sample, state = AbstractMCMC.step(

src/mcmc/gibbs.jl

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ function initial_varinfo(rng, model, spl, initial_params)
349349
# This is a quick fix for https://github.com/TuringLang/Turing.jl/issues/1588
350350
# and https://github.com/TuringLang/Turing.jl/issues/1563
351351
# to avoid that existing variables are resampled
352-
vi = last(DynamicPPL.evaluate!!(model, vi, DynamicPPL.DefaultContext()))
352+
vi = last(DynamicPPL.evaluate!!(model, vi))
353353
end
354354
return vi
355355
end
@@ -534,9 +534,7 @@ function setparams_varinfo!!(
534534
)
535535
# The state is already a VarInfo, so we can just return `params`, but first we need to
536536
# update its logprob.
537-
# NOTE: Using `leafcontext(model.context)` here is a no-op, as it will be concatenated
538-
# with `model.context` before hitting `model.f`.
539-
return last(DynamicPPL.evaluate!!(model, params, DynamicPPL.leafcontext(model.context)))
537+
return last(DynamicPPL.evaluate!!(model, params))
540538
end
541539

542540
function setparams_varinfo!!(
@@ -546,11 +544,8 @@ function setparams_varinfo!!(
546544
params::AbstractVarInfo,
547545
)
548546
# The state is already a VarInfo, so we can just return `params`, but first we need to
549-
# update its logprob. To do this, we have to call evaluate!! with the sampler, rather
550-
# than just a context, because ESS is peculiar in how it uses LikelihoodContext for
551-
# some variables and DefaultContext for others.
552-
# TODO(penelopeysm): Is this still needed?
553-
return last(DynamicPPL.evaluate!!(model, params, DynamicPPL.SamplingContext(sampler)))
547+
# update its logprob.
548+
return last(DynamicPPL.evaluate!!(model, params))
554549
end
555550

556551
function setparams_varinfo!!(

0 commit comments

Comments
 (0)