bartz.mcmcloop.PrintCallback¶
- class bartz.mcmcloop.PrintCallback(dot_every, report_every, accumulator)[source]¶
Progress-printing callback for
run_mcmc, create it withfrom_state.The callback prints a dot on every iteration, and a longer report periodically.
- dot_every: Int32[Array, ''] | None¶
A dot is printed every
dot_everyMCMC iterations,Noneto disable.
- report_every: Int32[Array, ''] | None¶
A one line report is printed every
report_everyMCMC iterations,Noneto disable.
- accumulator: StatsAccumulator¶
Running average of the reported statistics, inert unless averaging.
- classmethod from_state(state, *, dot_every=1, report_every=100, average=True)[source]¶
Prepare a progress-printing callback for
run_mcmc.- Parameters:
state (
State) – The MCMC state to use the callback with, used to determine device sharding.dot_every (
int|Integer[Array, '']|None, default:1) – A dot is printed everydot_everyMCMC iterations,Noneto disable.report_every (
int|Integer[Array, '']|None, default:100) – A one line report is printed everyreport_everyMCMC iterations,Noneto disable.average (
bool, default:True) – IfTrue, the reported statistics are averaged over the iterations since the previous report; ifFalse, they reflect the current iteration only. Ignored whenreport_everyisNone.
- Returns:
PrintCallback– A callback to pass as thecallbackargument ofrun_mcmc.
Examples
>>> run_mcmc(key, state, ..., callback=PrintCallback.from_state(state, ...))