Open chiyu1203 opened 1 year ago
Can you try running this with the most recent version of PyMC (v5)?
Can you try running this with the most recent version of PyMC (v5)?
Hello! I have tried the most recent version PyMC (v5). This time, I bumped into another error in an earlier cell so I am not sure if that would fix 5.34 Below is the new error I saw in 5.19
data["Divorce_std"] = standardize(data["Divorce"])
data["Marriage_std"] = standardize(data["Marriage"])
data["MedianAgeMarriage_std"] = standardize(data["MedianAgeMarriage"])
# Use Aesara shared variables so we can change them later
marriage_shared = shared(data["Marriage_std"].values)
age_shared = shared(data["MedianAgeMarriage_std"].values)
with pm.Model() as m5_3_A:
# A -> D <- M
sigma = pm.Exponential("sigma", 1)
bA = pm.Normal("bA", 0, 0.5)
bM = pm.Normal("bM", 0, 0.5)
a = pm.Normal("a", 0, 0.2)
mu = pm.Deterministic("mu", a + bA * age_shared + bM * marriage_shared)
divorce = pm.Normal("divorce", mu, sigma, observed=data["Divorce_std"].values)
# A -> M
sigma_M = pm.Exponential("sigma_m", 1)
bAM = pm.Normal("bAM", 0, 0.5)
aM = pm.Normal("aM", 0, 0.2)
mu_M = pm.Deterministic("mu_m", aM + bAM * age_shared)
marriage = pm.Normal("marriage", mu_M, sigma_M, observed=data["Marriage_std"].values)
m5_3_A_trace = pm.sample()
NotImplementedError Traceback (most recent call last) Cell In[33], line 16 13 bM = pm.Normal("bM", 0, 0.5) 15 a = pm.Normal("a", 0, 0.2) ---> 16 mu = pm.Deterministic("mu", a + bA age_shared + bM marriage_shared) 17 divorce = pm.Normal("divorce", mu, sigma, observed=data["Divorce_std"].values) 19 # A -> M
File ~\anaconda3\envs\pymc_env\Lib\site-packages\aesara\tensor\var.py:207, in _tensor_py_operators.rmul(self, other) 206 def rmul(self, other): --> 207 return at.math.mul(other, self)
File ~\anaconda3\envs\pymc_env\Lib\site-packages\aesara\graph\op.py:297, in Op.call(self, *inputs, *kwargs) 255 r"""Construct an
Apply
node using :meth:Op.make_node
and return its outputs. 256 257 This method is just a wrapper around :meth:Op.make_node
. (...) 294 295 """ 296 return_list = kwargs.pop("return_list", False) --> 297 node = self.make_node(inputs, **kwargs) 299 if config.compute_test_value != "off": 300 compute_test_value(node)File ~\anaconda3\envs\pymc_env\Lib\site-packages\aesara\tensor\elemwise.py:484, in Elemwise.make_node(self, inputs) 478 def make_node(self, inputs): 479 """ 480 If the inputs have different number of dimensions, their shape 481 is left-completed to the greatest number of dimensions with 1s 482 using DimShuffle. 483 """ --> 484 inputs = [as_tensor_variable(i) for i in inputs] 485 out_dtypes, out_shapes, inputs = self.get_output_info(DimShuffle, *inputs) 486 outputs = [ 487 TensorType(dtype=dtype, shape=shape)() 488 for dtype, shape in zip(out_dtypes, out_shapes) 489 ]
File ~\anaconda3\envs\pymc_env\Lib\site-packages\aesara\tensor\elemwise.py:484, in
(.0) 478 def make_node(self, inputs): 479 """ 480 If the inputs have different number of dimensions, their shape 481 is left-completed to the greatest number of dimensions with 1s 482 using DimShuffle. 483 """ --> 484 inputs = [as_tensor_variable(i) for i in inputs] 485 out_dtypes, out_shapes, inputs = self.get_output_info(DimShuffle, inputs) 486 outputs = [ 487 TensorType(dtype=dtype, shape=shape)() 488 for dtype, shape in zip(out_dtypes, out_shapes) 489 ] File ~\anaconda3\envs\pymc_env\Lib\site-packages\aesara\tensor__init__.py:49, in as_tensor_variable(x, name, ndim, kwargs) 17 def as_tensor_variable( 18 x: TensorLike, name: Optional[str] = None, ndim: Optional[int] = None, kwargs 19 ) -> "TensorVariable": 20 """Convert
x
into an equivalentTensorVariable
. 21 22 This function can be used to turn ndarrays, numbers,ScalarType
instances, (...) 47 48 """ ---> 49 return _as_tensor_variable(x, name, ndim, **kwargs)File ~\anaconda3\envs\pymc_env\Lib\functools.py:909, in singledispatch.
.wrapper(*args, *kw) 905 if not args: 906 raise TypeError(f'{funcname} requires at least ' 907 '1 positional argument') --> 909 return dispatch(args[0].class)(args, **kw) File ~\anaconda3\envs\pymc_env\Lib\site-packages\aesara\tensor__init__.py:56, in _as_tensor_variable(x, name, ndim, kwargs) 52 @singledispatch 53 def _as_tensor_variable( 54 x: TensorLike, name: Optional[str], ndim: Optional[int], kwargs 55 ) -> "TensorVariable": ---> 56 raise NotImplementedError(f"Cannot convert {x!r} to a tensor variable.")
NotImplementedError: Cannot convert bA to a tensor variable.
Last but not least, this is my computer setting:
Window11, anaconda, pymc v5
conda create -c conda-forge -n pymc_env "pymc>=5"
Libraries required for this notebook were installed as below:
pip install notebook, patsy, causalgraphicalmodels, daft, theano
conda install -c conda-forge watermark, seaborn, tqdm, aesara==2.8.7
Initially, I was hoping to install all the libraries according to the environment yaml file for pymc v4. However, there was some verion conflicts so I ended up installing some of the libraries via pip.
Please feel free to let me know if you have any thought.
I am using chapter 5 notebook. Everything worked until 5.34. which returned this error. Has anyone seen this before?
I use WIndow11, anaconda, pymc v4, installed via yaml file for v4
I have also registered this environment as the new kernel with the following command
python -m ipykernel install --user --name stat-rethink2-pymc3_4 --display-name "Python 3.10 (stat-rethink2-pymc3_4)"
Note that I have tried v3 version but it would return AttributeError: module 'numpy' has no attribute 'bool' when importing pymc3 That is why I continoue the rest of the cells with pymc v4.
Below is the problem cell I have and the returned error message.