From e480a791325074a525b460ab29a4608abab90dff Mon Sep 17 00:00:00 2001 From: Cameron Pfiffer Date: Wed, 12 Feb 2020 20:10:47 -0800 Subject: [PATCH 1/2] Remove state-saving by default --- src/inference/Inference.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/inference/Inference.jl b/src/inference/Inference.jl index d34c7b5754..c558c75601 100644 --- a/src/inference/Inference.jl +++ b/src/inference/Inference.jl @@ -326,7 +326,7 @@ function AbstractMCMC.bundle_samples( ts::Vector{<:AbstractTransition}, chain_type::Type{Chains}; discard_adapt::Bool=true, - save_state=true, + save_state=false, kwargs... ) # Check if we have adaptation samples. @@ -384,7 +384,7 @@ function AbstractMCMC.bundle_samples( ts::Vector{<:AbstractTransition}, chain_type::Type{Vector{NamedTuple}}; discard_adapt::Bool=true, - save_state=true, + save_state=false, kwargs... ) nts = Vector{NamedTuple}(undef, N) From f02ea0c7fd4aaf7363c9417f0ae40d2fd0ef549d Mon Sep 17 00:00:00 2001 From: Cameron Pfiffer Date: Tue, 18 Feb 2020 06:41:19 -0800 Subject: [PATCH 2/2] Add comment about save_state to logprob. --- docs/src/using-turing/guide.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/src/using-turing/guide.md b/docs/src/using-turing/guide.md index 2199aacd78..d73f083961 100644 --- a/docs/src/using-turing/guide.md +++ b/docs/src/using-turing/guide.md @@ -335,7 +335,9 @@ The following are examples of valid queries of the `Turing` model or chain: - `prob"s = 1.0, m = 1.0, x = 1.0, y = 1.0 | model = gdemo"` calculates the joint probability of all the variables. -- After the MCMC sampling, given a `chain`, `prob"x = 1.0, y = 1.0 | chain = chain"` calculates the element-wise likelihood of `x = 1.0` and `y = 1.0` for each sample in `chain`. +- After the MCMC sampling, given a `chain`, `prob"x = 1.0, y = 1.0 | chain = chain, model = gdemo"` calculates the element-wise likelihood of `x = 1.0` and `y = 1.0` for each sample in `chain`. + +- If `save_state=true` was used during sampling (i.e., `sample(model, sampler, N; save_state=true)`), you can simply do ``prob"x = 1.0, y = 1.0 | chain = chain"`. In all the above cases, `logprob` can be used instead of `prob` to calculate the log probabilities instead.