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

Convergence Logging #24

Open
mileslucas opened this issue Mar 25, 2020 · 8 comments
Open

Convergence Logging #24

mileslucas opened this issue Mar 25, 2020 · 8 comments

Comments

@mileslucas
Copy link
Contributor

Right now logging in the convergence sampling mode is almost useless. The @logprogress requires passing a fraction from 0 to 1, which isn't conducive to convergence logging at all. I realize this is backed up into the design of ProgressLogging.jl, which is even further backed up into the current logging backends, some parts end up tied directly into base julia. I've tried circumventing the issue by printing out my own statements but they actually get gobbled up due to the @withprogresslogging context.

I'm not sure the best path forward, other than re-introducing the ProgressMeter.jl dependency only for those sampling routines.

@devmotion
Copy link
Member

Do you have an example for what you tried and how it failed?

@mileslucas
Copy link
Contributor Author

mileslucas commented Mar 25, 2020

Inside my default convergence method:

# logging; don't even try to print every time
if progress && iszero(iteration % 10)
    print("dlogz threshold: $(dlogz_current) --> $(dlogz)\r")
end

I also tried printing to stderr instead of stdout, either way, this is all I ever see:

Convergence sampling 100%|███████████████████████████████████████████████████████████████████████████████████| Time: 0:00:00

(this is not different during the sampling, either)

I've also tried switching the carriage return to the beginning of the string instead of the end, with no improvement. I have tested using a basic for-loop that printing with a carriage return works for "logging", so I'm fairly confident the context is killing it.

@devmotion
Copy link
Member

Sorry, it's still unclear to me where exactly you put these lines of code and how you called them. Do you have a MWE or a link to a repo?

@mileslucas
Copy link
Contributor Author

mileslucas commented Mar 25, 2020

https://github.com/TuringLang/NestedSamplers.jl/blob/59191565d0163be14341fd1ab2f2d52c6674f7f3/src/NestedSamplers.jl#L309-L330

This is a function that is being passed to is_done in the sampling routine.

@devmotion
Copy link
Member

Ah OK, and do you have a MWE that I can run to reproduce the issue?

@mileslucas
Copy link
Contributor Author

mileslucas commented Mar 26, 2020

using NestedSamplers, StatsBase

priors = [Uniform(0, 1)]
model = NestedModel(p->rand(), priors)
samples = sample(model, Nested(10), dlogz=1e-5, chain_type=Array) 

It should "freeze" a little to show both during sampling and after sampling outputs

@mileslucas
Copy link
Contributor Author

See also: JuliaLogging/ProgressLogging.jl#27

@devmotion
Copy link
Member

Thanks for the MWE, I'll have a look at it. In principle, I think the right approach is to add support for convergence based logging upstream in ProgressLogging, as you already suggested, in a similar way as also the possibility to print additional information should preferably be added upstream (see JuliaLogging/ProgressLogging.jl#23).

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