AbstractVarInfo: the sampler interface #9
Replies: 2 comments 5 replies
-
It follows a summary of arguments and ideas brought forward in several issues about The essence:tm:, by Mohamed:
Linearization/vectorization and indexing
Interface cleanup/simplification
Other things
|
Beta Was this translation helpful? Give feedback.
-
First off, you're an awesome human being for bringing all this together into a readable format ❤️ I'll respond to different parts of the issue in different comments so that we can have separate threads discussing different parts of the design. First: linking. LinkingI think I'm of the opinion that this should always be done explicitly. Bijectors.jl can handle both linearized (using And "partial" transformations can be covered by just providing the Though making things explicit probably does help a lot with knowing whether it's unconstrained or not, we should still probably have a way of querying the support of the varinfo. We could do this by defining constraints and have bijectors act on the constraints, e.g. Maybe https://github.com/invenia/ParameterHandling.jl could be useful? TL;DR:
|
Beta Was this translation helpful? Give feedback.
-
VarInfo
really consists of multiple mappings:Metadata
maps variables to their values,their distributions, their range in the underlying vector, and additional metadata such as flags,
GIDs, and orders. Additionally, there are scalars
logp
andnum_produce
associated with the whole thing.getlogp
,setlogp!
,resetlogp!
, andacclogp!
for handling log probabilitiesgen_num_produce
,set_num_produce
,increment_num_produce
,reset_num_produce
; although theseare specific to particle samplers, and would ideally be handled by them (maybe with a custom
context in Turing?). A similar argument holds for the order information and certain flags.
Linking: Since I haven't yet written any HMC samplers or the like, I unfortunately don't know how
feasible/practical it is to make most of this more explicit. Mohamed, in a recent
PR, has introduced methods for the
getters/setters that take the distribution as additional argument to figure out the right thing:
Since that indexing in Julia supports keyword arguments, even somthing like the following would be possible:
vi[vn, link=dist]
The other getters and setters could then use the same kind of syntax.
Then, there would also have to be (I guess?) additional methods for the conversion methods, to
perform bijections for the array of vectorized values.
Also,
link!
/invlink!
for the complete mapping – is that necessary?Probably some resemblance of many of the old getters and setters:
getidx
,getdist
,getrange
,getall
,getval
,getvals
,getinds
,syms
,getgid
, flags. Hopefully some of them willbecome redundant.
There should be one well-defined way to build up a VarInfo object. Perhaps an empty one + muliple
calls to
push!
. What aboutpush!!
, with the possibility of immutable implementations?Alternatively: based on
merge
ing? Maybemerge
can be general enough to cover bothconstruction of all complex VarInfos, and producing
MixedVarInfo
s when required.Related work/discussions
VarInfo
/AbstractVarInfo
API DynamicPPL.jl#68Beta Was this translation helpful? Give feedback.
All reactions