PGM-Lab/InferPy

Error using MCMC

Opened this issue · 2 comments

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}}]]

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