Trace Translators

GenParticleFilters.jl provides two additional types of trace translators for use in particle filtering and sequential Monte Carlo algorithms.

Extending Trace Translator

This trace translator can be used to sample new latent variables from a custom proposal, then optionally apply a deterministic transform to those latent variables before they are used to update the model trace.

GenParticleFilters.ExtendingTraceTranslatorType
translator = ExtendingTraceTranslator(;
    p_new_args::Tuple = (),
    p_argdiffs::Tuple = (),
    new_observations::ChoiceMap = EmptyChoiceMap(),
    q_forward::Union{Nothing,GenerativeFunction} = nothing,
    q_forward_args::Tuple = (),
    transform::Union{TraceTransformDSLProgram,Nothing} = nothing
)

Constructor for an extending trace translator, which extends a trace by sampling new random choices from a forward proposal q_forward, optionally applying a trace transform to those choices, then updating the trace with the proposed (and transformed) choices, along with new_observations.

If q_forward is not specified, random choices are sampled from the default incremental proposal associated with the update method for the model's generative function.

source
Missing docstring.

Missing docstring for ExtendingTraceTranslator(::Trace). Check Documenter's build log for details.

Updating Trace Translator

This trace translator supports forward and backward proposals (which may include auxiliary randomness), as well as deterministic transformations between proposed choices and model choices.

GenParticleFilters.UpdatingTraceTranslatorType
translator = UpdatingTraceTranslator(;
    p_new_args::Tuple = (),
    p_argdiffs::Tuple = (),
    new_observations::ChoiceMap = EmptyChoiceMap(),
    q_forward::GenerativeFunction,
    q_forward_args::Tuple  = (),
    q_backward::GenerativeFunction,
    q_backward_args::Tuple  = (),
    transform::Union{TraceTransformDSLProgram,Nothing} = nothing
)

Constructor for a updating trace translator, which updates the trace of model given a forward proposal q_forward, backward proposal q_backward, new arguments for that model p_new_args, and new_observations.

Optionally, a trace transform can be provided, specifying how the input model trace and forward proposal trace get mapped to the output model trace and backward proposal trace.

When a transform is not provided, the update performed by an UpdatingTraceTranslator corresponds to Del Moral SMC [1]. When a transform is provided, the update corresponds to SMCP³ [2], a more general form of SMC that supports proposals with auxiliary randomness, as well as deterministic transformations between random variables in the model and the proposals.

[1] P. D. Moral, A. Doucet, and A. Jasra, "Sequential Monte Carlo samplers," Journal of the Royal Statistical Society: Series B (Statistical Methodology), vol. 68, no. 3, pp. 411–436, 2006.

[2] Lew, A. K., Matheos, G., Zhi-Xuan, T., Ghavamizadeh, M., Gothoskar, N., Russell, S., and Mansinghka, V. K. "SMCP3: Sequential Monte Carlo with Probabilistic Program Proposals.", AISTATS, 2023.

source
GenParticleFilters.UpdatingTraceTranslatorMethod
(output_trace, log_weight) = translator(input_trace; kwargs...)

Run an UpdatingTraceTranslator on an input trace, returning the output trace and the (incremental) importance weight.

Keyword Arguments

Set check = true to enable a bijection check (this requires that the transform has been paired with its inverse using pair_bijections! or is_involution!).

If check is enabled, then prev_observations should be provided as a choicemap containing the random choices in the input trace that are replaced by new_observations, or deleted due to a change in the arguments. Typically no observations are replaced or deleted, so prev_observations is an EmptyChoiceMap by default.

source