-
-
Notifications
You must be signed in to change notification settings - Fork 395
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
problem while processing pymc3 data #1279
Comments
Thanks for reporting, I have to admit I am completely at a loss as to why the "observed data" (in this case due to the structure of the DensityDist I think In the meantime I'd recommend using
I think both alternatives are equivalent implementations of the exact same model with the difference that as |
This is interesting to me -- when sampling starts, I see this, which I have never seen before:
@OriolAbril Are you familiar with this? Any idea whether this could be related to the later problem (which I am investigating now)? |
The error occurs while groveling over the Theano graph to decide how to categorize variables, to find the observations. It impinges on the This docstring is almost entirely unhelpful:
I have no clue what distinguishes a |
Yes, I also got this message which I had never seen before so I don't really know if it could have any relation with the |
Actually... isn't the answer to this simple? We have a variable whose "observed" values are not constant. So we shouldn't expect this to work, should we? I'm pretty sure that PyMC3 expects observations not to be random variables, right? I should mention that the Quickstart notebook for PyMC3 says: " The inclusion of |
Thank you for the detective work on this so far. I should've pointed out that the example comes from a pymc3 tutorial itself. I've been looking for exactly this kind of tutorial notebook for a long time, black box likelihoods are quite common in the area in which I work. Once the problem has been resolved, that may need to be updated. The reason the NUTS initialisation fails is because there is no gradient specified in the tensor op (so far). |
… 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.
* 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 <andorra.alexandre@gmail.com> Co-authored-by: Alexandre ANDORRA <andorra.alexandre@gmail.com> * Drop support for py3.6 (pymc-devs#3992) * Drop support for py3.6 * Update RELEASE-NOTES.md Co-authored-by: Colin <ColCarroll@users.noreply.github.com> Co-authored-by: Colin <ColCarroll@users.noreply.github.com> * 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 <aseyboldt@users.noreply.github.com> * 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 <junpenglao@gmail.com> * Use mp_ctx forkserver on MacOS * Add test for pickle with dill Co-authored-by: Junpeng Lao <junpenglao@gmail.com> * 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 <rpgoldman@sift.net> * 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 <brandonwillard@users.noreply.github.com> Co-authored-by: Bill Engels <w.j.engels@gmail.com> Co-authored-by: Oriol Abril-Pla <oriol.abril.pla@gmail.com> Co-authored-by: Osvaldo Martin <aloctavodia@gmail.com> Co-authored-by: Adrian Seyboldt <aseyboldt@users.noreply.github.com> Co-authored-by: Alexandre ANDORRA <andorra.alexandre@gmail.com> Co-authored-by: Colin <ColCarroll@users.noreply.github.com> Co-authored-by: Brandon T. Willard <brandonwillard@users.noreply.github.com> Co-authored-by: Junpeng Lao <junpenglao@gmail.com> Co-authored-by: rpgoldman <rpgoldman@goldman-tribe.org> Co-authored-by: Robert P. Goldman <rpgoldman@sift.net> Co-authored-by: Tirth Patel <tirthasheshpatel@gmail.com> Co-authored-by: Brandon T. Willard <971601+brandonwillard@users.noreply.github.com>
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.
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.
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.
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.
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.
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.
* Add basic MLDA-MCMC algorithm (proposal and step method) * Add example scripts for MLDA * Make coarse_models kwarg into a normal argument * Fix docstring in MLDA class * Fix examples code style/comments * Remove redundant code, improve comments * Make MLDA do block sampling by default * Add new MLDA example with FEniCS black box component * Small change in readme * Add run instructions in readme * Change example parameters in sample() * Minor changes and comments * Add extra parameters in readme * Number of chains change * Make changes to mlda example parameters, go back to compound sampling for mlda by default, edit readme accordingly * Updated the FEniCS code so it's more efficient * Add eigenpairs projection and change input parameters * Edit readme to reflect projection function * Add compound step support and improve example.py * Update readme * Add new tests tests, most of them failing * Fix test_types bug * Refactoring of MLDA to allow retaining all methods information * Add more tests * Pass more parameters to Metropolis init * Complete tuning continuation, add basic block/coumpound parameter * Remove some mlda if statements and simplify other parts * Change example parameters * Add and fix tests * Add some comments and remove redundant code * Add xfail to test_models_utils test when new pandas version are used * Add description to test_examples for multilevel normal example * Remove xfail related to pandas in test_models_utils, remove redundant function from test_step * Try removing failing test * Remove redundant code * Skip some failing tests * Add sine wave test in test_examples * Change true parameters index * Fix index j in coarse models loop to avoid warning * Remove sine test * Remove unused library * Improve docstrings and remove some redundant code/comments * Revert some pointless changes to tests * Fix style * Add notebook example and utility code * Remove old mlda example and update notebook * Update notebook again * Change the citation and add a use example to the MLDA docstring * Change competence to be incompatible with discrete vars, remove discrete var detection code from MLDA init * Add young warning and change default subsampling value * Add more comments, change sys.exit to exception, change tests to reflect that, convert coarse_models to positional argument in MLDA * Add is_mlda_flag to prevent tuning reset when Metropolis is used as the base sampler of MLDA * Add more extensive docstrings * Re-run and re-render notebook after changes * Add tuning for tune and scaling and refactor some parameter names to be consistent with what they represent * Regenerate notebook and add .py version of it * Delete notebook with old name * Fix pylint errors, move .py example, fix failing test * Add computer specs to notebook * Change class checks to using isinstance * Add more tests for stats, competence, etc and fix bug with tune flag not being overriden in compound sub-methods * Remove duplicate sample_except() * Move is_mlda_base checks for reseting inside Metropolis' reset_tuning() * Add DEMetropolis to notebook * Add MLDA groundwater flow notebook which uses blocked samplers only * Add comparison with DEMCMC-Z amd longer runs for convergence in example notebook * Add separate subsampling rates * Edit docstring * Fix handling of one integer for subsampling rate * Add tests and change subsampling argument name in examples/tests * Add notebook with extra benchmarks and tuning demo * Change subsampling rate to rates in notebook examples (including new benchmarking one) * Do not count stuck proposals from lower chain as accepted * Convert base_scaling stats to one stat of type object, modify tests for stats and also test for declining acceptance rate * Fix pm.DensityDist in notebooks/scripts by replacing with pm.Potential 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. * Move MLDA and RecursiveDAProposal classes to new mlda.py file, add a new MetropolisMLDA class which inherits Metropolis and just alters the reset_tuning function, modify test_step and __init__ files accordingly * Remove MLDA notebooks and .py example script, remove code that uses fenics and delete reference to example from MLDA class docstring * Blacken MLDA code and tests, separate MLDA type tests from other methods, fix some stylistic issues * Add simple linear regression notebook which can serve as MLDA starting point for new users * Modify some comments in the simple notebook and re-run * Add typing to mlda.py * Connect the two separate strings in mlda.py * Modify simple linear regression notebook: coarse model uses subset of data, more comments, performance comparison with Metropolis * Add more comments, format using PyMC3 NB style guide (blacken, watermark, arviz style, imports, etc) * Add simple regression notebook to table of examples * Add gravity surveying notebook * Add MLDA line in 3.9.x release notes * Edit notebook imports to adhere to nbqa-isort rules * Add gravity notebook to table of contents Co-authored-by: Mikkel Lykkegaard <mikkelbue@gmail.com>
Im not sure but I feel like this issue has been resolved. Closing for now and if Im mistaken someone comment and we can reopn |
I confirmed that using pm.Potential() works beautifully but not pm.DensityDist() |
I did also run into this issue, also following PyMC3 tutorials to add a custom (black-box) likelihood. I don't know the relation between arviz and pymc3, but this definitely is still a bug in one of the two libraries - at least in the documentation of pymc3. |
I'm unable to sample a blackbox likelihood in pymc3. There is an exception raised when arviz is asked to process the trace. Based on the stacktrace I think the issue is on the arviz side.
Python 3.8.3
pymc3 3.9.2
arviz 0.9.0
theano 1.0.4
macOS
all packages installed via pip into a clean conda env. The MWE is:
gives the stack trace:
The text was updated successfully, but these errors were encountered: