A model whose structure is static given its data, compiled to plain functions of its latent values, and inference on them without worlds, savepoints or continuations.
compile-model reads the model's instance graph (analysis/instance):
every site with a concrete address, a distribution written over constants
and the latent sites before it, and no site whose existence depends on a
value. It returns its latent addresses, a log density of a double array
of their values (the sum of every site's log density, as a run of the
model would score it) and a draw from the prior. rmh runs :rmh's
moves (one latent drawn uniformly, a Gaussian step of :step-size) on
that density: each move evaluates the density once, as Gen's dynamic MH
re-runs its program once, but as compiled code.
A model that does not qualify is refused with the reasons, so a caller can fall back to the general path.
A model whose structure is static given its data, compiled to plain functions of its latent values, and inference on them without worlds, savepoints or continuations. `compile-model` reads the model's instance graph (`analysis/instance`): every site with a concrete address, a distribution written over constants and the latent sites before it, and no site whose existence depends on a value. It returns its latent addresses, a log density of a double array of their values (the sum of every site's log density, as a run of the model would score it) and a draw from the prior. `rmh` runs `:rmh`'s moves (one latent drawn uniformly, a Gaussian step of `:step-size`) on that density: each move evaluates the density once, as Gen's dynamic MH re-runs its program once, but as compiled code. A model that does not qualify is refused with the reasons, so a caller can fall back to the general path.
(compile-model model & args)The model applied to args compiled: {:addresses [a …] :log-density
(fn [^doubles x]) :draw (fn [] ^doubles x)}, latent values in the order of
:addresses. Throws ::not-static with the refusals when it cannot be.
The model applied to `args` compiled: {:addresses [a …] :log-density
(fn [^doubles x]) :draw (fn [] ^doubles x)}, latent values in the order of
:addresses. Throws ::not-static with the `refusals` when it cannot be.(refusals {:keys [sites unknown]})Why the instance graph g cannot be compiled: a vector of reasons, empty
when it can.
Why the instance graph `g` cannot be compiled: a vector of reasons, empty when it can.
(rmh {:keys [addresses log-density draw]}
{:keys [iterations burn step-size chains] :or {burn 0 chains 4}})Random-walk MH on a compiled model (compile-model): :chains chains
(default 4) of :iterations moves, each moving one latent drawn uniformly
by a Gaussian step of :step-size, after :burn moves that are dropped.
Draws through foerster.random, so a seeded run repeats. Resolves (as a
CPS operation, like foerster.core/infer) an EmpiricalMeasure whose
samples' results are {address value} maps of the latents.
Random-walk MH on a compiled model (`compile-model`): `:chains` chains
(default 4) of `:iterations` moves, each moving one latent drawn uniformly
by a Gaussian step of `:step-size`, after `:burn` moves that are dropped.
Draws through `foerster.random`, so a seeded run repeats. Resolves (as a
CPS operation, like `foerster.core/infer`) an EmpiricalMeasure whose
samples' results are {address value} maps of the latents.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |