Issues trying to fit a basic model in Bean Machine
See original GitHub issueHi - I just came across Bean Machine on Twitter. This looks really cool! Thanks for all the hard work that went into this.
I was curious about Bean Machine and so took stab at implementing a simple IRT model in Bean Machine. (See blog post here: I wrote a quick blog post about my experience here: https://www.dougjohnson.in/post/stan-vs-pymc3-vs-bean-machine/) Unfortunately, I don’t think I got the model to work (the posterior distribution is quite a bit different from what I get when using Stan or PyMC3) and I found some of the documentation a bit confusing. I am definitely not a great programmer so my confusion could entirely be due to my lack of programming experience but I thought I’d share a bit about what I found confusing below in case it is helpful.
- When creating families of random variables, I was a bit confused when to use “.expand()” (as you guys do in the radon tutorial) and when to pass an index to the variable function definition (as you guy do in several of the other tutorials). More generally, I found the latter syntax pretty confusing.
- I wasn’t clear what the role of the function annotation “-> RVIdentifier”. This was included in some of the examples but not the others.
Finally, it would also be really cool if you allowed users to “step through” the prior predictive by first sampling from the priors and then from each random or deterministic variable in turn. This would be really useful for basic debugging and could be a big advantage of Bean Machine over Stan / PyMC3. (And apologies if this is possible, e.g. by creating a new World() instance, and I just missed it.)
Issue Description
A clear and concise description of the issue. If it’s a feature request, please add [Feature Request] to the title.
Steps to Reproduce
Please provide steps to reproduce the issue attaching any error messages and stack traces.
Expected Behavior
What did you expect to happen?
System Info
Please provide information about your setup
- PyTorch Version (run
print(torch.__version__)
- Python version
Additional Context
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top GitHub Comments
Thanks for the links! I think that is the general rule particularly with PyTorch libraries. Of course, we should probably raise warnings in the future.
@dougj892 I can confirm that @zaxtax’s solution fixes the issue. See below for a sampling of
student ability (θ)
posteriors from all three PPLs. I looked at the posteriors for the random variablesquestion difficulty (b)
,question discriminator (a)
, andguess (c)
and all were in close agreement.The important take-away here is that the observations dictionary should have values that are torch tensors, and the items in the tensors should not be integers.