PGM-Lab / InferPy

InferPy: Deep Probabilistic Modeling with Tensorflow Made Easy
https://inferpy-docs.readthedocs.io/en/stable/index.html
Apache License 2.0
147 stars 14 forks source link

Error using MCMC #204

Open doctorwes opened 4 years ago

doctorwes commented 4 years ago

I am using the same model as in #195 (closed; thank you!), but attempting to use MCMC rather than VI.

(Note that I can successfully run the sample notebook MCMC-logregression.ipynb)

MC = inf.inference.MCMC(num_results=1000)
m.fit({"x": data}, MC)

I get the following error:

---------------------------------------------------------------------------
FailedPreconditionError                   Traceback (most recent call last)
/home/wkp/.conda/envs/WKPenv/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
   1355     try:
-> 1356       return fn(*args)
   1357     except errors.OpError as e:

/home/wkp/.conda/envs/WKPenv/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run_fn(feed_dict, fetch_list, target_list, options, run_metadata)
   1340       return self._call_tf_sessionrun(
-> 1341           options, feed_dict, fetch_list, target_list, run_metadata)
   1342 

/home/wkp/.conda/envs/WKPenv/lib/python3.6/site-packages/tensorflow/python/client/session.py in _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list, run_metadata)
   1428         self._session, options, feed_dict, fetch_list, target_list,
-> 1429         run_metadata)
   1430 

FailedPreconditionError: Error while reading resource variable mcmc_sample_chain_1/mh_bootstrap_results/hmc_kernel_bootstrap_results/maybe_call_fn_and_grads/value_and_gradients/value_and_gradient/dense_40/bias from Container: localhost. This could mean that the variable was uninitialized. Not found: Resource localhost/mcmc_sample_chain_1/mh_bootstrap_results/hmc_kernel_bootstrap_results/maybe_call_fn_and_grads/value_and_gradients/value_and_gradient/dense_40/bias/N10tensorflow3VarE does not exist.
     [[{{node mcmc_sample_chain_1/mh_bootstrap_results/hmc_kernel_bootstrap_results/maybe_call_fn_and_grads/value_and_gradients/value_and_gradient/dense_40/BiasAdd/ReadVariableOp}}]]
rcabanasdepaz commented 4 years ago

For probabilistic models with (trainable) NNs, it is not possible to use MCMC. Instead, you should use variational inference.

doctorwes commented 4 years ago

Thank you for your advice - I was not aware of that.

Wesley Phoa

Sent

On Feb 24, 2020, at 2:58 AM, Rafael Cabañas de Paz notifications@github.com wrote:

 For probabilistic models with (trainable) NNs, it is not possible to use MCMC. Instead, you should use variational inference.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.