Closed marcoct closed 7 years ago
AIDE implementation simplified using the compose
module combinator:
"""
Estimate the KL divergence between two generators with the same output type.
AIDE: An algorithm for measuring the accuracy of probabilistic inference algorithms
Marco F. Cusumano-Towner, Vikash K. Mansinghka
https://arxiv.org/abs/1705.07224
"""
function aide(p::AtomicGenerator{T}, p_args::Tuple,
q::AtomicGenerator{T}, q_args::Tuple) where {T}
generator = compose(q, p, ())
(score, _) = generate!(generator, (q_args, p_args), AtomicTrace(T))
-score
end
export aide
Basic implementation in terms of atomic generators added at https://github.com/probcomp/Gen.jl/blob/59b1cfc6710fd0dc6c27b26c49d95f3fb7efb00c/src/aide.jl
It's quite simple. The details around multiple-sample replicates are taken care of the
replicate
generator combinator.Next step is to add a general-purpose SIR and SMC implementations, with
AtomicGenerator
views on these inference algorithms.