@@ -140,7 +140,9 @@ function is_target_varname(context::GibbsContext, vns::AbstractArray{<:VarName})
140
140
end
141
141
142
142
# Tilde pipeline
143
- function DynamicPPL. tilde_assume!! (context:: GibbsContext , right, vn, vi)
143
+ function DynamicPPL. tilde_assume!! (
144
+ context:: GibbsContext , right:: Distribution , vn:: VarName , vi:: DynamicPPL.AbstractVarInfo
145
+ )
144
146
child_context = DynamicPPL. childcontext (context)
145
147
146
148
# Note that `child_context` may contain `PrefixContext`s -- in which case
@@ -204,47 +206,6 @@ function DynamicPPL.tilde_assume!!(context::GibbsContext, right, vn, vi)
204
206
end
205
207
end
206
208
207
- # As above but with an RNG.
208
- function DynamicPPL. tilde_assume!! (
209
- rng:: Random.AbstractRNG , context:: GibbsContext , sampler, right, vn, vi
210
- )
211
- # See comment in the above, rng-less version of this method for an explanation.
212
- child_context = DynamicPPL. childcontext (context)
213
- vn, child_context = DynamicPPL. prefix_and_strip_contexts (child_context, vn)
214
-
215
- return if is_target_varname (context, vn)
216
- # This branch means that that `sampler` is supposed to handle
217
- # this variable. We can thus use its default behaviour, with
218
- # the 'local' sampler-specific VarInfo.
219
- DynamicPPL. tilde_assume!! (rng, child_context, sampler, right, vn, vi)
220
- elseif has_conditioned_gibbs (context, vn)
221
- # This branch means that a different sampler is supposed to handle this
222
- # variable. From the perspective of this sampler, this variable is
223
- # conditioned on, so we can just treat it as an observation.
224
- # The only catch is that the value that we need is to be obtained from
225
- # the global VarInfo (since the local VarInfo has no knowledge of it).
226
- # Note that tilde_observe!! will trigger resampling in particle methods
227
- # for variables that are handled by other Gibbs component samplers.
228
- val = get_conditioned_gibbs (context, vn)
229
- DynamicPPL. tilde_observe!! (child_context, right, val, vn, vi)
230
- else
231
- # If the varname has not been conditioned on, nor is it a target variable, its
232
- # presumably a new variable that should be sampled from its prior. We need to add
233
- # this new variable to the global `varinfo` of the context, but not to the local one
234
- # being used by the current sampler.
235
- value, new_global_vi = DynamicPPL. tilde_assume!! (
236
- # child_context might be a PrefixContext so we have to be careful to not
237
- # overwrite it.
238
- DynamicPPL. setleafcontext (child_context, DynamicPPL. InitContext (rng)),
239
- right,
240
- vn,
241
- get_global_varinfo (context),
242
- )
243
- set_global_varinfo! (context, new_global_vi)
244
- value, vi
245
- end
246
- end
247
-
248
209
"""
249
210
make_conditional(model, target_variables, varinfo)
250
211
@@ -363,7 +324,7 @@ function AbstractMCMC.step(
363
324
rng:: Random.AbstractRNG ,
364
325
model:: DynamicPPL.Model ,
365
326
spl:: DynamicPPL.Sampler{<:Gibbs} ;
366
- initial_params= nothing ,
327
+ initial_params:: DynamicPPL.AbstractInitStrategy = DynamicPPL . init_strategy (spl) ,
367
328
kwargs... ,
368
329
)
369
330
alg = spl. alg
@@ -388,7 +349,7 @@ function AbstractMCMC.step_warmup(
388
349
rng:: Random.AbstractRNG ,
389
350
model:: DynamicPPL.Model ,
390
351
spl:: DynamicPPL.Sampler{<:Gibbs} ;
391
- initial_params= nothing ,
352
+ initial_params:: DynamicPPL.AbstractInitStrategy = DynamicPPL . init_strategy (spl) ,
392
353
kwargs... ,
393
354
)
394
355
alg = spl. alg
@@ -425,7 +386,7 @@ function gibbs_initialstep_recursive(
425
386
samplers,
426
387
vi,
427
388
states= ();
428
- initial_params= nothing ,
389
+ initial_params,
429
390
kwargs... ,
430
391
)
431
392
# End recursion
@@ -436,13 +397,6 @@ function gibbs_initialstep_recursive(
436
397
varnames, varname_vecs_tail... = varname_vecs
437
398
sampler, samplers_tail... = samplers
438
399
439
- # Get the initial values for this component sampler.
440
- initial_params_local = if initial_params === nothing
441
- nothing
442
- else
443
- DynamicPPL. subset (vi, varnames)[:]
444
- end
445
-
446
400
# Construct the conditioned model.
447
401
conditioned_model, context = make_conditional (model, varnames, vi)
448
402
@@ -453,7 +407,7 @@ function gibbs_initialstep_recursive(
453
407
sampler;
454
408
# FIXME : This will cause issues if the sampler expects initial params in unconstrained space.
455
409
# This is not the case for any samplers in Turing.jl, but will be for external samplers, etc.
456
- initial_params= initial_params_local ,
410
+ initial_params= initial_params ,
457
411
kwargs... ,
458
412
)
459
413
new_vi_local = get_varinfo (new_state)
0 commit comments