Raster-compiled log densities as foerster blocks (doc/contract.md).
A raster block is a deftm log density over typed arguments. The block
says how θ and the site's inputs become those arguments, and which argument
slots hold θ:
(raster-block {:block/id :gauss :block/latents [{:name :mu :shape [2] :support :real}] :block/target :complete-conditional} #'gauss-lp {:args (fn [^doubles theta {:keys [ys n s0 s]}] [(aget theta 0) (aget theta 1) ys n s0 s]) :theta [0 1]})
:theta lists, in θ order, the argument slots θ occupies: a scalar slot
contributes one coordinate, an array slot as many as its gradient has.
The block's :log-density calls the compiled function; its :value+grad
calls raster's reverse mode (raster.ad.reverse/value+grad) with respect
to the θ slots only, built once per block: the other arguments (the data)
stay constant. Raster owns compilation and caching; this namespace only
binds arguments.
Raster-compiled log densities as foerster blocks (doc/contract.md).
A raster block is a `deftm` log density over typed arguments. The block
says how θ and the site's inputs become those arguments, and which argument
slots hold θ:
(raster-block {:block/id :gauss
:block/latents [{:name :mu :shape [2] :support :real}]
:block/target :complete-conditional}
#'gauss-lp
{:args (fn [^doubles theta {:keys [ys n s0 s]}]
[(aget theta 0) (aget theta 1) ys n s0 s])
:theta [0 1]})
`:theta` lists, in θ order, the argument slots θ occupies: a scalar slot
contributes one coordinate, an array slot as many as its gradient has.
The block's `:log-density` calls the compiled function; its `:value+grad`
calls raster's reverse mode (`raster.ad.reverse/value+grad`) with respect
to the θ slots only, built once per block: the other arguments (the data)
stay constant. Raster owns compilation and caching; this namespace only
binds arguments.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 |