Comments (2)
Can you try running this with the most recent version of PyMC (v5)?
from pymc-resources.
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 -> MFile ~\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 anApply
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 """Convertx
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.
from pymc-resources.
Related Issues (20)
- Add Bayes Rules Chapter 2 HOT 1
- Fix up env for bayes rules
- Chapter 5 - Code 5.29 should use log(mass) HOT 3
- Chp_02.ipynb, import statement HOT 2
- Conflicting chain size for code block 4.59
- causalgraphicalmodels import error with Python 3.10 HOT 5
- Chapter 5 import error when running pymc model HOT 9
- Chp_11 notebook - models not running - Got error No model on context stack
- Incompatibilities with Python 3.10 for the aesara 2.6.6 and causalgraphicalmodels-0.0.4 packages.
- issue importing pymc3 "cannot import as scalar from numpy"
- Error for code snippet 8.8 - NotImplementedError HOT 3
- Adding exposition about PyMC and Arviz to the Rethinking_2 code.
- Type error - Code 15.12 - pymc v4 HOT 4
- Rethinking_2/Chp_02.ipynb: Mistake in quadratic approximation ("Code 2.6")? HOT 5
- Resources/Rethinking_2/Chp_04.ipynb: The hyperlink in Code 4.26 is broken HOT 1
- Gender Categories in Chapter 4
- Using pymc (v5) to run rethinking notebooks HOT 1
- Sampling performance b-splines model chapter 04 HOT 1
- pre-commit is failing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pymc-resources.