Skip to content

Commit 798b89f

Browse files
gmingasbwengalsOriolAbrilaloctavodiaaseyboldt
authored
Fix pm.DensityDist bug and incorporate latest upstream changes (#42)
* Update GP NBs to use standard notebook style (pymc-devs#3978) * update gp-latent nb to use arviz * rerun, run black * rerun after fixes from comments * rerun black * rewrite radon notebook using ArviZ and xarray (pymc-devs#3963) * rewrite radon notebook using ArviZ and xarray Roughly half notebook has been updated * add comments on xarray usage * rewrite 2n half of notebook * minor fix * rerun notebook and minor changes * rerun notebook on pymc3.9.2 and ArviZ 0.9.0 * remove unused import * add change to release notes * SMC: refactor, speed-up and run multiple chains in parallel for diagnostics (pymc-devs#3981) * first attempt to vectorize smc kernel * add ess, remove multiprocessing * run multiple chains * remove unused imports * add more info to report * minor fix * test log * fix type_num error * remove unused imports update BF notebook * update notebook with diagnostics * update notebooks * update notebook * update notebook * Honor discard_tuned_samples during KeyboardInterrupt (pymc-devs#3785) * Honor discard_tuned_samples during KeyboardInterrupt * Do not compute convergence checks without samples * Add time values as sampler stats for NUTS (pymc-devs#3986) * Add time values as sampler stats for NUTS * Use float time counters for nuts stats * Add timing sampler stats to release notes * Improve doc of time related sampler stats Co-authored-by: Alexandre ANDORRA <[email protected]> Co-authored-by: Alexandre ANDORRA <[email protected]> * Drop support for py3.6 (pymc-devs#3992) * Drop support for py3.6 * Update RELEASE-NOTES.md Co-authored-by: Colin <[email protected]> Co-authored-by: Colin <[email protected]> * Fix Mixture distribution mode computation and logp dimensions Closes pymc-devs#3994. * Add more info to divergence warnings (pymc-devs#3990) * Add more info to divergence warnings * Add dataclasses as requirement for py3.6 * Fix tests for extra divergence info * Remove py3.6 requirements * follow-up of py36 drop (pymc-devs#3998) * Revert "Drop support for py3.6 (pymc-devs#3992)" This reverts commit 1bf867e. * Update README.rst * Update setup.py * Update requirements.txt * Update requirements.txt Co-authored-by: Adrian Seyboldt <[email protected]> * Show pickling issues in notebook on windows (pymc-devs#3991) * Merge close remote connection * Manually pickle step method in multiprocess sampling * Fix tests for extra divergence info * Add test for remote process crash * Better formatting in test_parallel_sampling Co-authored-by: Junpeng Lao <[email protected]> * Use mp_ctx forkserver on MacOS * Add test for pickle with dill Co-authored-by: Junpeng Lao <[email protected]> * Fix keep_size for arviz structures. (pymc-devs#4006) * Fix posterior pred. sampling keep_size w/ arviz input. Previously posterior predictive sampling functions did not properly handle the `keep_size` keyword argument when getting an xarray Dataset as parameter. Also extended these functions to accept InferenceData object as input. * Reformatting. * Check type errors. Make errors consistent across sample_posterior_predictive and fast_sample_posterior_predictive, and add 2 tests. * Add changelog entry. Co-authored-by: Robert P. Goldman <[email protected]> * SMC-ABC add distance, refactor and update notebook (pymc-devs#3996) * update notebook * move dist functions out of simulator class * fix docstring * add warning and test for automatic selection of sort sum_stat when using wassertein and energy distances * update release notes * fix typo * add sim_data test * update and add tests * update and add tests * add docs for interpretation of length scales in periodic kernel (pymc-devs#3989) * fix the expression of periodic kernel * revert change and add doc * FIXUP: add suggested doc string * FIXUP: revertchanges in .gitignore * Fix Matplotlib type error for tests (pymc-devs#4023) * Fix for issue 4022. Check for support for `warn` argument in `matplotlib.use()` call. Drop it if it causes an error. * Alternative fix. * Switch from pm.DensityDist to pm.Potential to describe the likelihood in MLDA notebooks and script examples. This is done because of the bug described in arviz-devs/arviz#1279. The commit also changes a few parameters in the MLDA .py example to match the ones in the equivalent notebook. * Remove Dirichlet distribution type restrictions (pymc-devs#4000) * Remove Dirichlet distribution type restrictions Closes pymc-devs#3999. * Add missing Dirichlet shape parameters to tests * Remove Dirichlet positive concentration parameter constructor tests This test can't be performed in the constructor if we're allowing Theano-type distribution parameters. * Add a hack to statically infer Dirichlet argument shapes Co-authored-by: Brandon T. Willard <[email protected]> Co-authored-by: Bill Engels <[email protected]> Co-authored-by: Oriol Abril-Pla <[email protected]> Co-authored-by: Osvaldo Martin <[email protected]> Co-authored-by: Adrian Seyboldt <[email protected]> Co-authored-by: Alexandre ANDORRA <[email protected]> Co-authored-by: Colin <[email protected]> Co-authored-by: Brandon T. Willard <[email protected]> Co-authored-by: Junpeng Lao <[email protected]> Co-authored-by: rpgoldman <[email protected]> Co-authored-by: Robert P. Goldman <[email protected]> Co-authored-by: Tirth Patel <[email protected]> Co-authored-by: Brandon T. Willard <[email protected]>
1 parent db022a5 commit 798b89f

39 files changed

+8651
-2524
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ benchmarks/results/
4141
pytestdebug.log
4242
.dir-locals.el
4343
.pycheckers
44+

RELEASE-NOTES.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
# Release Notes
22

33
## PyMC3 3.9.x (on deck)
4-
*waiting for contributions*
4+
5+
### Maintenance
6+
- Fix an error on Windows and Mac where error message from unpickling models did not show up in the notebook, or where sampling froze when a worker process crashed (see [#3991](https://github.com/pymc-devs/pymc3/pull/3991)).
7+
8+
### Documentation
9+
- Notebook on [multilevel modeling](https://docs.pymc.io/notebooks/multilevel_modeling.html) has been rewritten to showcase ArviZ and xarray usage for inference result analysis (see [#3963](https://github.com/pymc-devs/pymc3/pull/3963))
10+
11+
### New features
12+
- Introduce optional arguments to `pm.sample`: `mp_ctx` to control how the processes for parallel sampling are started, and `pickle_backend` to specify which library is used to pickle models in parallel sampling when the multiprocessing cnotext is not of type `fork`. (see [#3991](https://github.com/pymc-devs/pymc3/pull/3991))
13+
- Add sampler stats `process_time_diff`, `perf_counter_diff` and `perf_counter_start`, that record wall and CPU times for each NUTS and HMC sample (see [ #3986](https://github.com/pymc-devs/pymc3/pull/3986)).
14+
- Extend `keep_size` argument handling for `sample_posterior_predictive` and `fast_sample_posterior_predictive`, to work on arviz InferenceData and xarray Dataset input values. (see [PR #4006](https://github.com/pymc-devs/pymc3/pull/4006) and [Issue #4004](https://github.com/pymc-devs/pymc3/issues/4004).
15+
- SMC-ABC: add the wasserstein and energy distance functions. Refactor API, the distance, sum_stats and epsilon arguments are now passed `pm.Simulator` instead of `pm.sample_smc`. Add random method to `pm.Simulator`. Add option to save the simulated data. Improves LaTeX representation [#3996](https://github.com/pymc-devs/pymc3/pull/3996)
516

617
## PyMC3 3.9.2 (24 June 2020)
718
### Maintenance
819
- Warning added in GP module when `input_dim` is lower than the number of columns in `X` to compute the covariance function (see [#3974](https://github.com/pymc-devs/pymc3/pull/3974)).
920
- Pass the `tune` argument from `sample` when using `advi+adapt_diag_grad` (see issue [#3965](https://github.com/pymc-devs/pymc3/issues/3965), fixed by [#3979](https://github.com/pymc-devs/pymc3/pull/3979)).
10-
- Add simple test case for new coords and dims feature in `pm.Model` (see [#3977](https://github.com/pymc-devs/pymc3/pull/3977)).
21+
- Add simple test case for new coords and dims feature in `pm.Model` (see [#3977](https://github.com/pymc-devs/pymc3/pull/3977)).
1122
- Require ArviZ >= 0.9.0 (see [#3977](https://github.com/pymc-devs/pymc3/pull/3977)).
1223

1324
_NB: The `docs/*` folder is still removed from the tarball due to an upload size limit on PyPi._

docs/source/notebooks/Bayes_factor.ipynb

+112-61
Large diffs are not rendered by default.

docs/source/notebooks/GP-Latent.ipynb

+357-178
Large diffs are not rendered by default.

docs/source/notebooks/MLDA_benchmarks_tuning.ipynb

+5-5
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@
231231
" # convert m and c to a tensor vector\n",
232232
" theta = tt.as_tensor_variable(parameters)\n",
233233
"\n",
234-
" # use a DensityDist (use a lamdba function to \"call\" the Op)\n",
234+
" # use a Potential for the likelihood\n",
235235
" ll = logl[j]\n",
236-
" pm.DensityDist('likelihood', lambda v: ll(v), observed={'v': theta})\n",
236+
" pm.Potential('likelihood', ll(theta))\n",
237237
"\n",
238238
" coarse_models.append(cmodel)\n",
239239
" \n",
@@ -248,8 +248,8 @@
248248
" # Convert m and c to a tensor vector\n",
249249
" theta = tt.as_tensor_variable(parameters)\n",
250250
"\n",
251-
" # use a DensityDist (use a lamdba function to \"call\" the Op)\n",
252-
" pm.DensityDist('likelihood', lambda v: logl[-1](v), observed={'v': theta})\n",
251+
" ## use a Potential for the likelihood\n",
252+
" pm.Potential('likelihood', logl[-1](theta))\n",
253253
" \n",
254254
" return model, coarse_models, true_parameters"
255255
]
@@ -2716,7 +2716,7 @@
27162716
"source": [
27172717
"Generally, the optimal subsampling rate depends on the complexity of the fine posterior. The more complex the posterior, the more samples are needed to generate a decent proposal. The reason is that the MLDA sampler is based on the assumption that the coarse proposal samples (i.e. the samples sent from the coarse chain to the fine one) are independent from each other. In order to generate independent samples, it is necessary to run the coarse chain for an adequate number of iterations to get rid of autocorrelation. The more complex the posterior the more iterations are needed and thus a larger subsampling rate.\n",
27182718
"\n",
2719-
"Note that in cases where you have more than one coarse model/level, MLDA allows you to choose a different subsampling rate for each coarse level (as a list of integers when you instantiate the stepper)."
2719+
"Note that in cases where you have more than one coarse model/level, MLDA allows you to choose a different subsampling rate for each coarse level (as a list of integers when you instantiate the stepper)."
27202720
]
27212721
}
27222722
],

docs/source/notebooks/MLDA_multilevel_groundwater_flow.ipynb

+4-4
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,9 @@
352352
" # convert m and c to a tensor vector\n",
353353
" theta = tt.as_tensor_variable(parameters)\n",
354354
"\n",
355-
" # use a DensityDist (use a lamdba function to \"call\" the Op)\n",
355+
" # use a Potential for the likelihood\n",
356356
" ll = logl[j]\n",
357-
" pm.DensityDist('likelihood', lambda v: ll(v), observed={'v': theta})\n",
357+
" pm.Potential('likelihood', ll(theta))\n",
358358
"\n",
359359
" coarse_models.append(model)\n"
360360
]
@@ -599,8 +599,8 @@
599599
" # Convert m and c to a tensor vector\n",
600600
" theta = tt.as_tensor_variable(parameters)\n",
601601
"\n",
602-
" # use a DensityDist (use a lamdba function to \"call\" the Op)\n",
603-
" pm.DensityDist('likelihood', lambda v: logl[-1](v), observed={'v': theta})\n",
602+
" # use a Potential for the likelihood\n",
603+
" pm.Potential('likelihood', logl[-1](theta))\n",
604604
"\n",
605605
" # Initialise an MLDA step method object, passing the subsampling rate and\n",
606606
" # coarse models list\n",

docs/source/notebooks/MLDA_multilevel_groundwater_flow_blocked.ipynb

+4-4
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,9 @@
352352
" # convert m and c to a tensor vector\n",
353353
" theta = tt.as_tensor_variable(parameters)\n",
354354
"\n",
355-
" # use a DensityDist (use a lamdba function to \"call\" the Op)\n",
355+
" # use a Potential for the likelihood\n",
356356
" ll = logl[j]\n",
357-
" pm.DensityDist('likelihood', lambda v: ll(v), observed={'v': theta})\n",
357+
" pm.Potential('likelihood', ll(theta))\n",
358358
"\n",
359359
" coarse_models.append(model)\n"
360360
]
@@ -557,8 +557,8 @@
557557
" # Convert m and c to a tensor vector\n",
558558
" theta = tt.as_tensor_variable(parameters)\n",
559559
"\n",
560-
" # use a DensityDist (use a lamdba function to \"call\" the Op)\n",
561-
" pm.DensityDist('likelihood', lambda v: logl[-1](v), observed={'v': theta})\n",
560+
" # use a Potential for the likelihood\n",
561+
" pm.Potential('likelihood', logl[-1](theta))\n",
562562
"\n",
563563
" # Initialise an MLDA step method object, passing the subsampling rate and\n",
564564
" # coarse models list\n",

docs/source/notebooks/SMC-ABC_Lotka-Volterra_example.ipynb

+138-201
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)