question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issues trying to fit a basic model in Bean Machine

See original GitHub issue

Hi - 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.

  1. 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.
  2. 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:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
zaxtaxcommented, Jan 9, 2022

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.

1reaction
ndmlny-qscommented, Jan 7, 2022

@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 variables question difficulty (b), question discriminator (a), and guess (c) and all were in close agreement.

ppl-posteriors

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

beanmachine/Neals_funnel.ipynb at main - GitHub
This tutorial demonstrates modeling and running inference on the so-called Neal's funnel model in Bean Machine. Neal's funnel has proven difficult-to-handle ...
Read more >
Why Bean Machine?
Bean Machine is a probabilistic programming language that makes developing and deploying generative probabilistic models intuitive and efficient.
Read more >
Simulating the bean machine - Summer School of Science Blog
We're doing this issue's DIY Science a bit unconventionally: today, you'll write your own program to simulate a bean machine, also known as ......
Read more >
Stan vs PyMC3 vs Bean Machine - Doug Johnson
My attempt to fit the 3PL model in Bean Machine is below. You can find a Colab notebook with this code here. import...
Read more >
Beans Diesel Fuel Tank Sump (New Bean Machine) Install
New and approved design! Beans multi-function sump (supply/return into one). What we have done at BDP is step the tank sump up a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found