Open thegallier opened 6 years ago
Figured it out. There were 2 issues. Iteritems is no longer supported in Python 3.6. Replacing it with items works (interceptor). _load_observed and _load_unobserved need to be called in Model.
Can someone provide some context about the status of this proposed high-level API? It seems to be more natural way of doing Bayesian statistics but it seems a bit under-documented presently.
FWIW, I made a branch (https://github.com/kyleabeauchamp/probability/tree/api) of TFP that adds the higher level api as a module and fixes the iteritems bug, but I'm still figuring out why _load_observed()
is never called...
For even more concise syntax, it might be nice for the Model class to provide a @decorator for wrapping a single function, similar to https://github.com/ColCarroll/sampled
@jsafyan wrote that notebook. Perhaps he can comment?
Hi, thanks for the interest in the notebook. To give some context, this is just a single early design sketch that was made public to facilitate a discussion with the open source community.
I suggest sticking to Edward2, which is production-ready and tested (and increasingly well documented). It's gotten additional features since this was written too: the recent addition of the Tape interceptor makes one of the patterns here easier, for example. @dustinvtran has a great Edward -> Edward2 guide here:
Best practices will likely continue to evolve, so I'd keep an eye on Edward2 and TFP generally, as well as PyMC4.
As to the details of the notebook, _load_observed()
and _load_unobserved()
are both called when an instance of BaseModel
is instantiated. The metaclass MetaModel
calls the two methods and returns the instance. See, e.g., this Stack Overflow thread. That said, there are many possible approaches (both in terms of API and implementation) to provide a wrapper for Edward2. If I were to re-write this notebook today, I'd do things a bit differently and avoid metaprogramming.
model.observed and model.unobserved are not defined even though notebook has the results. So it looks look code is out of sync with results.
Section
The model keeps track of observed and unobserved variables. The data / observed variables are specified when the model is first created. The unobserved variables and their shapes can be inferred using Edward2 random variable interception -- this facilitates automatically creating the log joint.