Skip to content

Commit 05dddb1

Browse files
committed
add experimental warning message add change to release note
1 parent 7f8a40c commit 05dddb1

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

RELEASE-NOTES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Release Notes
22

33

4+
## PyMC3 3.6 (unreleased)
5+
6+
- Renamed `sample_ppc()` and `sample_ppc_w()` to `sample_posterior_predictive()` and `sample_posterior_predictive_w()`, respectively.
7+
- Refactor SMC and properly compute marginal likelihood (#3124)
8+
49
## PyMC 3.5 (July 21 2018)
510

611
### New features
@@ -436,3 +441,4 @@ Thus, Thomas, Chris and I are pleased to announce that PyMC3 is now in Beta.
436441
* maahnman <[email protected]>
437442
* paul sorenson <[email protected]>
438443
* zenourn <[email protected]>
444+

pymc3/step_methods/smc.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import theano
66
import pymc3 as pm
77
from tqdm import tqdm
8+
import warnings
89

910
from .arraystep import metrop_select
1011
from .metropolis import MultivariateNormalProposal
@@ -57,7 +58,6 @@ class SMC():
5758
816-832. `link <http://ascelibrary.org/doi/abs/10.1061/%28ASCE%290733-9399
5859
%282007%29133:7%28816%29>`__
5960
"""
60-
default_blocked = True
6161

6262
def __init__(self, n_steps=5, scaling=1., p_acc_rate=0.01, tune=True,
6363
proposal_name='MultivariateNormal', threshold=0.5):
@@ -88,14 +88,15 @@ def sample_smc(draws=5000, step=None, progressbar=False, model=None, random_seed
8888
random_seed : int
8989
random seed
9090
"""
91+
warnings.warn("Warning: SMC is experimental, hopefully it will be ready for PyMC 3.6")
9192
model = modelcontext(model)
9293

9394
if random_seed != -1:
9495
np.random.seed(random_seed)
9596

9697
beta = 0
9798
stage = 0
98-
acc_rate = 0
99+
acc_rate = 1
99100
model.marginal_likelihood = 1
100101
variables = model.vars
101102
discrete = np.concatenate([[v.dtype in pm.discrete_types] * (v.dsize or 1) for v in variables])
@@ -113,7 +114,6 @@ def sample_smc(draws=5000, step=None, progressbar=False, model=None, random_seed
113114
likelihoods = np.array([likelihood_logp(sample) for sample in posterior]).squeeze()
114115
beta, old_beta, weights, sj = _calc_beta(beta, likelihoods, step.threshold)
115116
model.marginal_likelihood *= sj
116-
pm._log.info('Beta: {:f} Stage: {:d}'.format(beta, stage))
117117
# resample based on plausibility weights (selection)
118118
resampling_indexes = np.random.choice(np.arange(draws), size=draws, p=weights)
119119
posterior = posterior[resampling_indexes]
@@ -129,8 +129,10 @@ def sample_smc(draws=5000, step=None, progressbar=False, model=None, random_seed
129129
if acc_rate == 0:
130130
acc_rate = 1. / step.n_steps
131131
step.scaling = _tune(acc_rate)
132-
step.n_steps = 1 + (np.ceil(np.log(step.p_acc_rate) / np.log(1 - acc_rate)).astype(int))
132+
step.n_steps = 1 + int(np.log(step.p_acc_rate) / np.log(1 - acc_rate))
133133

134+
pm._log.info('Stage: {:d} Beta: {:f} Steps: {:d} Acc: {:f}'.format(stage, beta,
135+
step.n_steps, acc_rate))
134136
# Apply Metropolis kernel (mutation)
135137
proposed = 0.
136138
accepted = 0.

0 commit comments

Comments
 (0)