Pymc3: Stopping sampling early, similarly to pm.fit method

Created on 6 Jun 2019  路  6Comments  路  Source: pymc-devs/pymc3

When working with Pymc3, I find most of the time that even the smallest realistic models I can create, on a decently fast work-station, take at least a few minutes to run.

That being the case that probably everyone has to deal with, what would it take to implement something like pm.fit's early halting method (which is found a bit toward the bottom under "hard stop"), if a particular instance is taking too long to run?

I've looked into the matter, in pm.fit and callbacks' sources (and if my analysis is amateurish, please do correct me), and it seems that callback by default keeps track of 1) the amount of time the model has been going, and 2) how many its/sec is occurring atm. To halt the model early, it calls StopIteration (line 173), which then primarily calls progress.close().

My question is if within sample it would make sense to code in StopIteration to hijack KeyboardInterrupt's activity (such as line 990) to similarly halt models?

Any advice would be welcome.

beginner friendly feature request

Most helpful comment

I think a callback for pm.sample() is a great feature request.

All 6 comments

To clarify, you're asking for an "elegant" way to do this, right? It sounds like you spotted that KeyboardInterrupt will save progress.

Well, yes, because reusing the current functionality in this way seems not only to be clean and elegant, but wouldn't clutter up the code-base.

I think a callback for pm.sample() is a great feature request.

Going through the codebase, could someone help explain what exactly is fed into tqdm to create the progress-bar that allows it to estimate a time to completion? _iter_sample (596) feeds an iterable object in, but I'm having trouble making sense of it.

Hi I'd like to work on this. If it's available can someone tell me which part of code is this related to? And some basic reading material before I dive into the code?

This issue looks fixed but thanks @Overlord2335.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

junpenglao picture junpenglao  路  20Comments

MisterRedactus picture MisterRedactus  路  22Comments

fonnesbeck picture fonnesbeck  路  88Comments

aloctavodia picture aloctavodia  路  19Comments

JackCaster picture JackCaster  路  27Comments