Closed
Description
Description of the problem
The multivariate distribution fails here:
import numpy as np
import pymc3 as pm
pm.MvNormal.dist(mu = np.array([0, 0]), cov = np.diag([1, 1])).logp(np.array([1, 1])).eval()
with the error
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-17-f2b19e774b86> in <module>()
1 mvdist = pm.MvNormal.dist(mu = np.array([0, 0]), cov = np.diag([1, 1]))
2 testData = np.array([1, 1])
----> 3 r = mvdist.logp(testData).eval()
~/Envs/noteEnv2/lib/python3.5/site-packages/pymc3/distributions/multivariate.py in logp(self, value)
272 def logp(self, value):
273 quaddist, logdet, ok = self._quaddist(value)
--> 274 k = value.shape[-1].astype(theano.config.floatX)
275 norm = - 0.5 * k * pm.floatX(np.log(2 * np.pi))
276 return bound(norm - 0.5 * quaddist - logdet, ok)
AttributeError: 'int' object has no attribute 'astype'
It seems value.shape
is aspected to have the astype
callable, like a numpy array but is only a python base tuple:
type(np.array([1, 1]).shape)
> tuple
Overwriting the shape by a numpy array did not do the trick:
testData = np.array([1, 1])
testData.shape = np.array(testData.shape)
type(testData.shape)
> tuple
Versions and main components
- PyMC3 Version: 3.4.1
- Theano Version: 1.0.5
- Python Version: 3.5.2
- Operating system: Ubuntu 16.04.4 LTS
- How did you install PyMC3: pip install git+https://github.com/pymc-devs/pymc3