Skip to content

Commit bf8552e

Browse files
authored
Drop nuts init method from pm.sample (#3863)
* Dropped nuts init method * Dropped nuts init method from tests * Refined doc string and added release note
1 parent de0024c commit bf8552e

File tree

3 files changed

+4
-16
lines changed

3 files changed

+4
-16
lines changed

Diff for: RELEASE-NOTES.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Deprecated `sd` in version 3.7 has been replaced by `sigma` now raises `DepreciationWarning` on using `sd` in continuous, mixed and timeseries distributions. (see #3837 and #3688).
1919
- In named models, `pm.Data` objects now get model-relative names (see [#3843](https://github.com/pymc-devs/pymc3/pull/3843)).
2020
- `pm.sample` now takes 1000 draws and 1000 tuning samples by default, instead of 500 previously (see [#3855](https://github.com/pymc-devs/pymc3/pull/3855)).
21+
- Dropped the outdated 'nuts' initialization method for `pm.sample` (see [#3863](https://github.com/pymc-devs/pymc3/pull/3863)).
2122

2223
## PyMC3 3.8 (November 29 2019)
2324

Diff for: pymc3/sampling.py

+2-14
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,14 @@ def sample(
274274
* advi: Run ADVI to estimate posterior mean and diagonal mass matrix.
275275
* advi_map: Initialize ADVI with MAP and use MAP as starting point.
276276
* map: Use the MAP as starting point. This is discouraged.
277-
* nuts: Run NUTS and estimate posterior mean and mass matrix from the trace.
278277
* adapt_full: Adapt a dense mass matrix using the sample covariances
279278
step: function or iterable of functions
280279
A step function or collection of functions. If there are variables without step methods,
281280
step methods for those variables will be assigned automatically. By default the NUTS step
282281
method will be used, if appropriate to the model; this is a good default for beginning
283282
users.
284283
n_init: int
285-
Number of iterations of initializer. Only works for 'nuts' and 'ADVI'.
286-
If 'ADVI', number of iterations, if 'nuts', number of draws.
284+
Number of iterations of initializer. Only works for 'ADVI' init methods.
287285
start: dict, or array of dict
288286
Starting point in parameter space (or partial point)
289287
Defaults to ``trace.point(-1))`` if there is a trace provided and model.test_point if not
@@ -1865,14 +1863,11 @@ def init_nuts(
18651863
* advi: Run ADVI to estimate posterior mean and diagonal mass matrix.
18661864
* advi_map: Initialize ADVI with MAP and use MAP as starting point.
18671865
* map: Use the MAP as starting point. This is discouraged.
1868-
* nuts: Run NUTS and estimate posterior mean and mass matrix from
1869-
the trace.
18701866
* adapt_full: Adapt a dense mass matrix using the sample covariances
18711867
chains: int
18721868
Number of jobs to start.
18731869
n_init: int
1874-
Number of iterations of initializer
1875-
If 'ADVI', number of iterations, if 'nuts', number of draws.
1870+
Number of iterations of initializer. Only works for 'ADVI' init methods.
18761871
model: Model (optional if in ``with`` context)
18771872
progressbar: bool
18781873
Whether or not to display a progressbar for advi sampling.
@@ -2001,13 +1996,6 @@ def init_nuts(
20011996
cov = pm.find_hessian(point=start)
20021997
start = [start] * chains
20031998
potential = quadpotential.QuadPotentialFull(cov)
2004-
elif init == "nuts":
2005-
init_trace = pm.sample(
2006-
draws=n_init, step=pm.NUTS(), tune=n_init // 2, random_seed=random_seed
2007-
)
2008-
cov = np.atleast_1d(pm.trace_cov(init_trace))
2009-
start = list(np.random.choice(init_trace, chains))
2010-
potential = quadpotential.QuadPotentialFull(cov)
20111999
elif init == "adapt_full":
20122000
start = [model.test_point] * chains
20132001
mean = np.mean([model.dict_to_array(vals) for vals in start], axis=0)

Diff for: pymc3/tests/test_sampling.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def test_sample(self):
8787

8888
def test_sample_init(self):
8989
with self.model:
90-
for init in ("advi", "advi_map", "map", "nuts"):
90+
for init in ("advi", "advi_map", "map"):
9191
pm.sample(
9292
init=init,
9393
tune=0,
@@ -675,7 +675,6 @@ def test_sample_posterior_predictive_w(self):
675675
"advi+adapt_diag_grad",
676676
"map",
677677
"advi_map",
678-
"nuts",
679678
],
680679
)
681680
def test_exec_nuts_init(method):

0 commit comments

Comments
 (0)