Skip to content

Conversation

tyarkoni
Copy link
Contributor

Per #1606, this just sets the number of batches used in statfuncs to the number of samples if smaller than 100. I made the default value None now, as it seemed like bad practice to silently replace an int value with a smaller one, but if you'd prefer to make the default 100, and raise a warning if a smaller value is used, I can tweak this.

varnames = [name for name in trace.varnames if not name.endswith('_')]

if batches is None:
batches = min([100, len(trace)])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think trace is a dictionary here -- could this happen down after flat_vals is defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do that, but then batches could potentially take on a different value for each variable, which seems problematic (and would also require defining the stat func lambdas inside the varnames loop, since the values are bound by then). I don't really see a problem with doing it this way, since this is really just designed to catch the corner case where someone is testing or debugging a model with a tiny number of samples. It's a safe approach, in the sense that len(trace) is guaranteed to give a smaller value than the number of flattened samples. So I'd prefer to keep it this way...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, sorry, I had a bad memory -- I knew trace was a dictionary-like object, so I thought len would be the number of keys. Turns out it is overridden, so you're getting what is intended.

@ColCarroll ColCarroll merged commit 628cb52 into pymc-devs:master Dec 16, 2016
@ColCarroll
Copy link
Member

ColCarroll commented Dec 16, 2016

Thanks for this by the way -- I'd run into the same problem with models sampling slowly, then failing to print a summary when I cancelled them after fewer than 100 samples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants