arviz-devs / arviz

Exploratory analysis of Bayesian models with Python
https://python.arviz.org
Apache License 2.0
1.59k stars 395 forks source link

Unnecessary warning while running SMC via pymc3 #924

Closed aakhmetz closed 4 years ago

aakhmetz commented 4 years ago

When I do SMC on pymc3 with the command:

with pm.Model() as model:
        ...
        trace = pm.sample_smc(2000, cores=48, parallel=True, random_seed=123)

I receive the warning:

WARNING:arviz.stats.stats_utils:Shape validation failed: input_shape: (1, 2000), minimum_shape: (chains=2, draws=4)

Although, as it was adviced by @aloctavodia in https://github.com/pymc-devs/pymc3/issues/3697, it could be just one chain in SMC

(PyMC ver 3.8, arviz ver is latest from github)

ColCarroll commented 4 years ago

This is tough to track down - I would guess the fix will be applied to PyMC3, since it looks like the warning is correct, and something in PyMC3 is being too eager at running convergence checks.

We can leave the issue open here, though.

aloctavodia commented 4 years ago

This is superweird as pm.sample_smc does not run any convergence checks. Also I am unable to reproduce this warning message

aakhmetz commented 4 years ago

@aloctavodia and @ColCarroll, please excuse me, I think I missed that the error arises when I do az.summary (I was a bit too quick)

aloctavodia commented 4 years ago

Hi @aakhmetz, that's OK, now this error sounds more reasonable. Although is still a little bit annoying.

At this point ArviZ is more focused on working with samples coming from MCMC samplers, and this error is a reflection of that. In the near future we have plans to introduce diagnostics specifically tailored for other methods like SMC and Variational Inference. In the meantime you can safely ignore this warning message.

aakhmetz commented 4 years ago

Dear @aloctavodia, thanks! It looks good, so I will wait for some update!

ps: today I checked my previous code which had an error https://discourse.pymc.io/t/pm-smc-how-to-deal-with-numpy-linalg-linalgerror-xx-th-leading-minor-of-the-array-is-not-positive-definite/3643/6, and it worked smoothly with the latest version. Let's see how it goes :-)