Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progress bar #53

Closed
adam-coogan opened this issue Feb 23, 2021 · 2 comments
Closed

Progress bar #53

adam-coogan opened this issue Feb 23, 2021 · 2 comments

Comments

@adam-coogan
Copy link

Hi! Is there an easy way to add a progress bar to monitor sampling? If not, it would be great to add this using e.g. ProgressMeter.jl.

@mileslucas
Copy link
Collaborator

mileslucas commented Feb 23, 2021

Believe it or not there is actually already a progress bar- it just doesn't work due to upstream issues (TuringLang/AbstractMCMC.jl#24, JuliaLogging/ProgressLogging.jl#27, JuliaLogging/ProgressLogging.jl#32).

I am working on a better solution that also prints out convergence information as part of #46. For now, this is how I hook up a progress bar with ProgressMeter.jl using the callback interface

using ProgressMeter
using StatsFuns: logaddexp
function conv_callback(rng, m, sampler, t, iteration; pbar, dlogz=0.5, kwargs...)
    # Don't accidentally short-circuit
    iteration > 2 || return false
    logz_remain = maximum(sampler.active_logl) - (iteration - 1) / sampler.nactive
    dlogz_current = logaddexp(sampler.logz, logz_remain) - sampler.logz
    ProgressMeter.update!(pbar, dlogz_current)
    return dlogz_current < dlogz
end
ns = Nested(3, 500)
out = sample(model, ns, conv_callback; pbar=ProgressThresh(0.5, "ΔlnZ = "));

@mileslucas
Copy link
Collaborator

The newest release (v0.6.0) has a hand-written status output now, which works okay although I'd like to see a more refined solution in the future. Here is an example of what that looks like (in addition to the ProgressLogging.jl progress bar)-
Screenshot 2021-04-12 003753

I'm going to go ahead and close this, but if you have any problems or want to reopen discussion, don't hesitate to open this back up!

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

No branches or pull requests

2 participants