-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unified Infer function for marginal inference (with single options
argument)
#86
Comments
In the interest of unifying the interface, and rather than breaking the current fns, I'd prefer to see a new function |
Btw. it would be neat if the options structure for SMC was somewhat compositional. E.g.:
|
Slight variation on the theme:
This might make it easier to pick out the method/algorithm, especially when passing the model as an anonymous function. At the risk of revealing my ignorance, I admit that when I first looked at webppl I was confused by the way in which I get that this doesn't really work when you don't have |
Good point: probably we should call it By the same token, I prefer putting the method in the options object, because even though it isn't quite as easy to pick out the algroithm, it better supports the compositional descriptions of how to infer. |
Just wanted to weigh in while this is still open: If we're changing the interface to inference algs, I'd appreciate it if the individual sampling functions (e.g. My reasoning here is that the current scheme (i.e. all of the sampling functions returning marginalized ERPs directly) is great for discrete inference problems, but maybe not so much for continuous ones, and especially not for programs that return giant data structures (e.g. procedural models). In these cases, having the option to go straight to the raw samples can be much nicer. As things stand, I currently have to hack every single sampling function I want to use to give it an option to just store the raw samples--ugly, and results in a lot of repeated code. |
Is this just a side-effect of us doing |
For algorithms like MH, you'd still need to store the order of the samples somewhere, right? Otherwise, you can't run convergence diagnostics. |
I'd not considered that, though I get the impression that this isn't @dritchie's motivation for wanting samples. (Which is the thing I'm trying to understand.) If this is the case, I wonder if it might be handled through callbacks/hooks. So we might have things like:
|
Besides keeping track of sample order, another potential motivation for having samples instead of counts may be the fear that alternative ways for getting unique ids (~ hashes) from big data structure samples will be comparably inefficient to |
I can think of two ways of doing this which are within easy reach of the current implementation. First something like this: SMC(model, { rejuvKernel: 'MH' })
SMC(model, { rejuvKernel: { HMC: { stepSize: 0.01 } } })
MCMC(model, { kernel: { sequence: [{ MH: { discreteOnly: true } }, 'HMC'] } }) The second, something like: SMC(model, { rejuvKernel: MH() })
SMC(model, { rejuvKernel: { HMC({ stepSize: 0.01 }) })
MCMC(model, { kernel: { sequence(MH({ discreteOnly: true }), HMC()) } }) This second approach is a little bit problematic because we already have a Are either of these reasonable things to implement for now, or is there something better we can do which moves us closer to the interface we'd like for |
i like the first approach, as it is closer to what i have in mind for the -N On Thu, Nov 5, 2015 at 10:43 AM, null-a notifications@github.com wrote:
|
Agreed, I think it's fine to go ahead and implement the first approach. |
options
argumentoptions
argument)
From Noah:
Update: Now #437 |
My plan for the initial implementation of this is to add a new function to the header which simply looks at This ends up looking like: Infer(thunk, {method: 'MCMC', kernel: 'HMC', samples: 10})
Infer(thunk, {method: 'SMC', rejuvSteps: 1})
Infer(thunk, {method: 'Enumerate', maxExecutions: 10})
Infer(thunk, {method: 'IncrementalMH', samples: 100, justSample: true})
// etc.
The only small complication I've run into so far is the fact that we need to update the check we make to decide whether to run the caching transform. At present this simply looks for the identifier
@ngoodman: Do you still think it's preferable not change the interface of the current inference methods? The implementation of |
I'm a little bit concerned about the readability of the current approach when using an anonymous function for the program/model: Infer(function() {
//
//
//
// many more lines of code...
}, {method: 'MCMC'}) For any given call to I wonder if we should flip the arguments: Infer({method: 'MCMC'}, function() {
//
//
//
// many more lines of code
}); This might get a bit messy when there are lots of options, but something like the following seems tolerable: Infer({
method: 'MCMC'
samples: 10,
burn: 10,
lag: 2,
kernel: 'HMC'
}, function() {
//
//
//
// many more lines of code
}); |
i agree -- let's switch the order of args to Infer. (if you submit a pr with just this i can review / merge.) |
Now #433. The only snag with this signature for |
Options can then be an object such as:
The text was updated successfully, but these errors were encountered: