Created
February 28, 2016 13:38
-
-
Save axsk/4c32dcd0c7a90a483077 to your computer and use it in GitHub Desktop.
mamba.jl: proof of per-chain tune reset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
After applying | |
``` diff | |
diff --git a/src/model/mcmc.jl b/src/model/mcmc.jl | |
index 8dc127c..30e3e61 100644 | |
--- a/src/model/mcmc.jl | |
+++ b/src/model/mcmc.jl | |
@@ -61,9 +61,12 @@ end | |
function mcmc_worker!(args::Vector) | |
m, state, window, burnin, thin, meter = args | |
+ @show pointer_from_objref(m) | |
m.iter = first(window) - 1 | |
relist!(m, state.value) | |
settune!(m, state.tune) | |
+ @show pointer_from_objref(m.samplers[1].tune) | |
+ @show m.samplers[1].tune | |
pnames = names(m, true) | |
sim = Chains(last(window), length(pnames), start=burnin + thin, thin=thin, | |
diff --git a/src/samplers/sampler.jl b/src/samplers/sampler.jl | |
index 4032b7b..70aa579 100644 | |
--- a/src/samplers/sampler.jl | |
+++ b/src/samplers/sampler.jl | |
@@ -37,6 +37,7 @@ function SamplerVariate{T<:SamplerTune, U<:Real}(x::AbstractVector{U}, | |
s::Sampler{T}, | |
pargs...; kargs...) | |
if any(map(f -> !isdefined(s.tune, f), fieldnames(s.tune))) | |
+ info("resetting sampler ", typeof(s)) | |
v = SamplerVariate{T}(x, pargs...; kargs...) | |
s.tune = v.tune | |
else | |
``` | |
running the seeds example | |
``` julia | |
> julia -q doc/examples/seeds.jl ~/.julia/v0.4/Mamba | |
MCMC Simulation of 12500 Iterations x 2 Chains... | |
pointer_from_objref(m) = Ptr{Void} @0x00007f7bf434a690 | |
pointer_from_objref(m.samplers[1].tune) = Ptr{Void} @0x00007f7bf5ec7170 | |
m.samplers[1].tune = Mamba.AMMTune(#undef,true,2.812953e-318,1,#undef,#undef,6.92576150559095e-310,#undef,#undef) | |
INFO: resetting sampler Mamba.Sampler{Mamba.AMMTune} | |
INFO: resetting sampler Mamba.Sampler{Mamba.AMWGTune} | |
INFO: resetting sampler Mamba.Sampler{Mamba.AMWGTune} | |
Chain 1: 0% [1:56:07 of 1:56:13 remaining] | |
Chain 1: 10% [0:01:22 of 0:01:31 remaining] | |
... | |
pointer_from_objref(m) = Ptr{Void} @0x00007f7bf434a690 | |
pointer_from_objref(m.samplers[1].tune) = Ptr{Void} @0x00007f7bf5eb3b70 | |
m.samplers[1].tune = Mamba.AMMTune(#undef,true,2.812953e-318,1,#undef,#undef,6.92576150559095e-310,#undef,#undef) | |
INFO: resetting sampler Mamba.Sampler{Mamba.AMMTune} | |
INFO: resetting sampler Mamba.Sampler{Mamba.AMWGTune} | |
INFO: resetting sampler Mamba.Sampler{Mamba.AMWGTune} | |
Chain 2: 0% [0:00:33 of 0:00:33 remaining] | |
Chain 2: 10% [0:00:31 of 0:00:35 remaining] | |
... | |
> julia -q -p2 doc/examples/seeds.jl ~/.julia/v0.4/Mamba | |
MCMC Simulation of 12500 Iterations x 2 Chains... | |
From worker 3: pointer_from_objref(m) = Ptr{Void} @0x00007fc3e80d2b90 | |
From worker 2: pointer_from_objref(m) = Ptr{Void} @0x00007f8e7eda0010 | |
From worker 3: pointer_from_objref(m.samplers[1].tune) = Ptr{Void} @0x00007fc3ea7fd0a0 | |
From worker 3: m.samplers[1].tune = Mamba.AMMTune(#undef,true,2.812953e-318,2,#undef,#undef,6.92780252952843e-310,#undef,#undef) | |
From worker 2: pointer_from_objref(m.samplers[1].tune) = Ptr{Void} @0x00007f8e819fe5e0 | |
From worker 2: m.samplers[1].tune = Mamba.AMMTune(#undef,true,2.812953e-318,2,#undef,#undef,6.92780252952843e-310,#undef,#undef) | |
INFO: resetting sampler Mamba.Sampler{Mamba.AMMTune} | |
INFO: resetting sampler Mamba.Sampler{Mamba.AMMTune} | |
INFO: resetting sampler Mamba.Sampler{Mamba.AMWGTune} | |
INFO: resetting sampler Mamba.Sampler{Mamba.AMWGTune} | |
INFO: resetting sampler Mamba.Sampler{Mamba.AMWGTune} | |
INFO: resetting sampler Mamba.Sampler{Mamba.AMWGTune} | |
From worker 3: Chain 2: 0% [2:01:49 of 2:01:55 remaining] | |
From worker 2: Chain 1: 0% [2:02:33 of 2:02:39 remaining] | |
From worker 3: Chain 2: 10% [0:01:23 of 0:01:32 remaining] | |
From worker 2: Chain 1: 10% [0:01:22 of 0:01:31 remaining] | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As one can see, each sampler gets reseted once per chain.