probmods / webppl

Probabilistic programming for the web
http://webppl.org
Other
619 stars 86 forks source link

Instrument inference algorithms with hooks #197

Open null-a opened 9 years ago

null-a commented 9 years ago

This was originally raised as part of #64.

Also, instrument inference algorithms with hooks such that we can pass in functions to collect and compute diagnostics without the diagnostics code being part of the core algorithms.

These hooks might also be used to implement the --verbose option of MCMC. (Coming in #169.)

null-a commented 8 years ago

I have a branch where I've been playing with adding callbacks/hooks to MCMC. At the moment you pass an object something like the following to MCMC:

{
  init: function() {},
  iteration: function(trace) {},
  finish: function() {}
}

The functions get called when you would expect. It should be pretty easy to implement #257 with this.

My current thinking is that these callbacks will be written in js rather than wppl as hooking these into inference if they are in CPS appears a bit fiddly.

Another thought is that it might be useful to see if we can make this general enough to allow us to have generic progress indicators (implemented as callbacks) which work across all inference algorithms.