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

Resume interface #566

Closed
trappmartin opened this issue Sep 28, 2018 · 1 comment
Closed

Resume interface #566

trappmartin opened this issue Sep 28, 2018 · 1 comment

Comments

@trappmartin
Copy link
Member

Currently, we have two different ways to resume a sampling process.

@model gdemo(x) = begin
  s ~ InverseGamma(2,3)
  m ~ Normal(0, sqrt(s))
  x[1] ~ Normal(m, sqrt(s))
  x[2] ~ Normal(m, sqrt(s))
  return s, m
end
chn1 = sample(gdemo([1.5, 2.0]), sampler; save_state=true)

# version 1
resume(chn1, 1000)

# version 2
sample(gdemo([1.5, 2.0]), sampler; resume_from=chn1)

where the resume function is basically an alias for the second version.

One drawback of the current approach is that we need to store the model function, sampler and further information inside the Chains type.

save!(c::Chain, spl::Sampler, model::Function, vi) = begin
c.info[:spl] = spl
c.info[:model] = model
c.info[:vi] = deepcopy(vi)
end

From my point of view, resuming a sampling process should no restrict the user to a particular sampler but rather to a class of samplers. If I understand the HMC code on this correctly, we currently discard the selected HMC algorithm if we resume a sampling.

spl = reuse_spl_n > 0 ?
resume_from.info[:spl] :
Sampler(alg, adapt_conf)

Question 1: Would it be better to store only the type of the sampler or do we want to keep the sampler as a whole and instead adjust the code base so that we do not discard the user specified algorithm? Keeping the sampler would have the advantage that we can resume with exactly the same parameters.

Question 2: Is there a way that we can drop the VarInfo instance? Many fields can be recovered from the Chains type while others, e.g.

rvs :: Dict{Union{VarName,Vector{VarName}},Any}
dists :: Vector{Distributions.Distribution}
gids :: Vector{Int}
are not recoverable unless we adjust the Chains type. I feel we should think about a refactoring of this.

cc: @yebai @xukai92

@yebai
Copy link
Member

yebai commented Sep 18, 2019

Closed by #793

@yebai yebai closed this as completed Sep 18, 2019
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