pymc-devs / pymc-resources

PyMC educational resources
MIT License
1.96k stars 745 forks source link

Using pymc (v5) to run rethinking notebooks #232

Open chiyu1203 opened 1 year ago

chiyu1203 commented 1 year ago

Hello pymc team, I bumped into some error in using pymc v4 or pymc v3 (see previous issue raised by me), so I tried running the rethinking notebook with pymc v5 to see if things would get better. Computer environment: 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.

conda install -c conda-forge numpy=1.23 I have also downgraded numpy to avoid

Attributeerror: module has no attribute bool error

Overall I would summarised the errors as (1) unable convert tensor variable. from chapter 5,11,14,16 (2) ParallelSamplingError from chapter 7, 12 (3) others

Below are the errors I have found in those chapters: chp5: 5.19

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)

NotImplementedError: Cannot convert bA to a tensor variable.

chp7 Code 7.16


RemoteTraceback Traceback (most recent call last) RemoteTraceback: """ Traceback (most recent call last): File "C:\Users\einat\anaconda3\envs\pymc_env\Lib\site-packages\pymc\sampling\parallel.py", line 112, in _unpickle_step_method self._step_method = cloudpickle.loads(self._step_method) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: __generator_ctor() takes from 0 to 1 positional arguments but 2 were given

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\einat\anaconda3\envs\pymc_env\Lib\site-packages\pymc\sampling\parallel.py", line 120, in run self._unpickle_step_method() File "C:\Users\einat\anaconda3\envs\pymc_env\Lib\site-packages\pymc\sampling\parallel.py", line 114, in _unpickle_step_method raise ValueError(unpickle_error) ValueError: The model could not be unpickled. This is required for sampling with more than one core and multiprocessing context spawn or forkserver. """

The above exception was the direct cause of the following exception:

ValueError Traceback (most recent call last) ValueError: The model could not be unpickled. This is required for sampling with more than one core and multiprocessing context spawn or forkserver.

The above exception was the direct cause of the following exception:

ParallelSamplingError Traceback (most recent call last) Cell In[56], line 18 16 print(f"Num Params: {j}") 17 for i in tqdm.tqdm(range(1, tries + 1)): ---> 18 tr, te = sim_train_test(N=n, k=param, samples=1000) 19 train.append(tr), test.append(te) 20 r[j - 2, :] = ( 21 np.mean(train), 22 np.std(train, ddof=1), 23 np.mean(test), 24 np.std(test, ddof=1), 25 )

Cell In[55], line 31, in sim_train_test(N, k, rho, b_sigma, samples) 28 y = pm.Normal("y", mu=mu, sigma=1, observed=x_train[:, 0].reshape(-1, 1)) 30 with m_sim: ---> 31 trace_m_sim = pm.sample(samples, progressbar=False) 33 vec = az.summary(trace_m_sim)["mean"][:n_dim] 34 vec = np.array([i for i in vec]).reshape(n_dim, -1)

File ~\anaconda3\envs\pymc_env\Lib\site-packages\pymc\sampling\mcmc.py:766, in sample(draws, tune, chains, cores, random_seed, progressbar, step, nuts_sampler, initvals, init, jitter_max_retries, n_init, trace, discard_tuned_samples, compute_convergence_checks, keep_warning_stat, return_inferencedata, idata_kwargs, nuts_sampler_kwargs, callback, mp_ctx, model, kwargs) 764 _print_step_hierarchy(step) 765 try: --> 766 _mp_sample(sample_args, **parallel_args) 767 except pickle.PickleError: 768 _log.warning("Could not pickle model, sampling singlethreaded.")

File ~\anaconda3\envs\pymc_env\Lib\site-packages\pymc\sampling\mcmc.py:1155, in _mp_sample(draws, tune, step, chains, cores, random_seed, start, progressbar, traces, model, callback, mp_ctx, **kwargs) 1153 try: 1154 with sampler: -> 1155 for draw in sampler: 1156 strace = traces[draw.chain] 1157 strace.record(draw.point, draw.stats)

File ~\anaconda3\envs\pymc_env\Lib\site-packages\pymc\sampling\parallel.py:448, in ParallelSampler.iter(self) 445 self._progress.update(self._total_draws) 447 while self._active: --> 448 draw = ProcessAdapter.recv_draw(self._active) 449 proc, is_last, draw, tuning, stats = draw 450 self._total_draws += 1

File ~\anaconda3\envs\pymc_env\Lib\site-packages\pymc\sampling\parallel.py:330, in ProcessAdapter.recv_draw(processes, timeout) 328 else: 329 error = RuntimeError(f"Chain {proc.chain} failed.") --> 330 raise error from old_error 331 elif msg[0] == "writing_done": 332 proc._readable = True

ParallelSamplingError: Chain 0 failed with: The model could not be unpickled. This is required for sampling with more than one core and multiprocessing context spawn or forkserver.

chp8 Code 8.1:

TypeError Traceback (most recent call last) Cell In[30], line 3 1 fig, axs = plt.subplots(1, 2, figsize=(12, 6), sharey=True) ----> 3 sns.regplot(dd.loc[dd["cont_africa"] == 1]["rugged_std"], 4 dd.loc[dd["cont_africa"] == 1]["log_gdp_std"], 5 scatter_kws={"color": "b"}, 6 line_kws={"color": "k"}, 7 ax=axs[0], 8 ) 10 sns.regplot( 11 dd.loc[dd["cont_africa"] == 0]["rugged_std"], 12 dd.loc[dd["cont_africa"] == 0]["log_gdp_std"], (...) 15 ax=axs[1], 16 ) 18 axs[0].set_ylabel("log GDP (as proportion of mean)")

TypeError: regplot() takes from 0 to 1 positional arguments but 2 positional arguments (and 3 keyword-only arguments) were given

Chp11 Code 11.16 and 11.17


TypeError Traceback (most recent call last) Cell In[17], line 2 1 with m11_4: ----> 2 pm.set_data({"actor_id": np.repeat(range(7), 4), "treat_id": list(range(4)) * 7}) 3 ppd = pm.sample_posterior_predictive(trace_11_4, random_seed=RANDOM_SEED, var_names=["p"])[ 4 "posterior_predictive" 5 ]["p"] 6 p_mu = np.array(ppd.mean(["chain", "draw"])).reshape((7, 4))

File ~\anaconda3\envs\pymc_env\Lib\site-packages\pymc\model.py:1972, in set_data(new_data, model, coords) 1969 model = modelcontext(model) 1971 for variable_name, new_value in new_data.items(): -> 1972 model.set_data(variable_name, new_value, coords=coords)

File ~\anaconda3\envs\pymc_env\Lib\site-packages\pymc\model.py:1135, in Model.set_data(self, name, values, coords) 1133 shared_object = self[name] 1134 if not isinstance(shared_object, SharedVariable): -> 1135 raise TypeError( 1136 f"The variable {name} must be a SharedVariable" 1137 " (created through pm.MutableData() or pm.Data(mutable=True)) to allow updating. " 1138 f"The current type is: {type(shared_object)}" 1139 ) 1141 if isinstance(values, list): 1142 values = np.array(values)

TypeError: The variable actor_id must be a SharedVariable (created through pm.MutableData() or pm.Data(mutable=True)) to allow updating. The current type is: <class 'pytensor.tensor.var.TensorConstant'>

Chp12: Code 12.2


RemoteTraceback Traceback (most recent call last) RemoteTraceback: """ Traceback (most recent call last): File "C:\Users\einat\anaconda3\envs\pymc_env\Lib\site-packages\pymc\sampling\parallel.py", line 112, in _unpickle_step_method self._step_method = cloudpickle.loads(self._step_method) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: __generator_ctor() takes from 0 to 1 positional arguments but 2 were given

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\einat\anaconda3\envs\pymc_env\Lib\site-packages\pymc\sampling\parallel.py", line 120, in run self._unpickle_step_method() File "C:\Users\einat\anaconda3\envs\pymc_env\Lib\site-packages\pymc\sampling\parallel.py", line 114, in _unpickle_step_method raise ValueError(unpickle_error) ValueError: The model could not be unpickled. This is required for sampling with more than one core and multiprocessing context spawn or forkserver. """

The above exception was the direct cause of the following exception:

ValueError Traceback (most recent call last) ValueError: The model could not be unpickled. This is required for sampling with more than one core and multiprocessing context spawn or forkserver.

The above exception was the direct cause of the following exception:

ParallelSamplingError Traceback (most recent call last) Cell In[16], line 10 6 pbar = pm.Deterministic("pbar", pm.math.invlogit(a[gid])) 8 A = pm.BetaBinomial("A", pbar theta, (1.0 - pbar) theta, N, observed=admit_df.admit.values) ---> 10 trace_12_1 = pm.sample(random_seed=RANDOM_SEED)

File ~\anaconda3\envs\pymc_env\Lib\site-packages\pymc\sampling\mcmc.py:766, in sample(draws, tune, chains, cores, random_seed, progressbar, step, nuts_sampler, initvals, init, jitter_max_retries, n_init, trace, discard_tuned_samples, compute_convergence_checks, keep_warning_stat, return_inferencedata, idata_kwargs, nuts_sampler_kwargs, callback, mp_ctx, model, kwargs) 764 _print_step_hierarchy(step) 765 try: --> 766 _mp_sample(sample_args, **parallel_args) 767 except pickle.PickleError: 768 _log.warning("Could not pickle model, sampling singlethreaded.")

File ~\anaconda3\envs\pymc_env\Lib\site-packages\pymc\sampling\mcmc.py:1155, in _mp_sample(draws, tune, step, chains, cores, random_seed, start, progressbar, traces, model, callback, mp_ctx, **kwargs) 1153 try: 1154 with sampler: -> 1155 for draw in sampler: 1156 strace = traces[draw.chain] 1157 strace.record(draw.point, draw.stats)

File ~\anaconda3\envs\pymc_env\Lib\site-packages\pymc\sampling\parallel.py:448, in ParallelSampler.iter(self) 445 self._progress.update(self._total_draws) 447 while self._active: --> 448 draw = ProcessAdapter.recv_draw(self._active) 449 proc, is_last, draw, tuning, stats = draw 450 self._total_draws += 1

File ~\anaconda3\envs\pymc_env\Lib\site-packages\pymc\sampling\parallel.py:330, in ProcessAdapter.recv_draw(processes, timeout) 328 else: 329 error = RuntimeError(f"Chain {proc.chain} failed.") --> 330 raise error from old_error 331 elif msg[0] == "writing_done": 332 proc._readable = True

ParallelSamplingError: Chain 0 failed with: The model could not be unpickled. This is required for sampling with more than one core and multiprocessing context spawn or forkserver.

Chp13 code 13.4


TypeError Traceback (most recent call last) File ~\anaconda3\envs\pymc_env\Lib\site-packages\arviz\stats\stats.py:448, in _calculate_ics(compare_dict, scale, ic, var_name) 447 try: --> 448 compare_dict[name] = ic_func( 449 convert_to_inference_data(dataset), 450 pointwise=True, 451 scale=scale, 452 var_name=var_name, 453 ) 454 except Exception as e:

File ~\anaconda3\envs\pymc_env\Lib\site-packages\arviz\stats\stats.py:1613, in waic(data, pointwise, var_name, scale, dask_kwargs) 1612 inference_data = convert_to_inference_data(data) -> 1613 log_likelihood = _get_log_likelihood(inference_data, var_name=var_name) 1614 scale = rcParams["stats.ic_scale"] if scale is None else scale.lower()

File ~\anaconda3\envs\pymc_env\Lib\site-packages\arviz\stats\stats_utils.py:425, in get_log_likelihood(idata, var_name) 424 if not hasattr(idata, "log_likelihood"): --> 425 raise TypeError("log likelihood not found in inference data object") 426 if var_name is None:

TypeError: log likelihood not found in inference data object

The above exception was the direct cause of the following exception:

TypeError Traceback (most recent call last) File ~\anaconda3\envs\pymc_env\Lib\site-packages\arviz\stats\stats.py:177, in compare(compare_dict, ic, method, b_samples, alpha, seed, scale, var_name) 176 try: --> 177 (ics_dict, scale, ic) = _calculate_ics(compare_dict, scale=scale, ic=ic, var_name=var_name) 178 except Exception as e:

File ~\anaconda3\envs\pymc_env\Lib\site-packages\arviz\stats\stats.py:455, in _calculate_ics(compare_dict, scale, ic, var_name) 454 except Exception as e: --> 455 raise e.class( 456 f"Encountered error trying to compute {ic} from model {name}." 457 ) from e 458 return (compare_dict, scale, ic)

TypeError: Encountered error trying to compute waic from model m13_1.

The above exception was the direct cause of the following exception:

TypeError Traceback (most recent call last) Cell In[6], line 1 ----> 1 az.compare({"m13_1": trace_13_1, "m13_2": trace_13_2})

File ~\anaconda3\envs\pymc_env\Lib\site-packages\arviz\stats\stats.py:179, in compare(compare_dict, ic, method, b_samples, alpha, seed, scale, var_name) 177 (ics_dict, scale, ic) = _calculate_ics(compare_dict, scale=scale, ic=ic, var_name=var_name) 178 except Exception as e: --> 179 raise e.class("Encountered error in ELPD computation of compare.") from e 180 names = list(ics_dict.keys()) 181 if ic == "loo":

TypeError: Encountered error in ELPD computation of compare.

Chp14 Code 14.12


NotImplementedError Traceback (most recent call last) Cell In[15], line 12 9 a = pm.Normal("a", 5.0, 2.0) # prior for average intercept 10 b = pm.Normal("b", -1.0, 0.5) # prior for average slope 11 ab_cafe = pm.MvNormal( ---> 12 "ab_cafe", mu=at.stack([a, b]), chol=chol, shape=(N_cafes, 2) 13 ) # population of varying effects 14 # shape needs to be (N_cafes, 2) because we're getting back both a and b for each cafe 16 mu = ab_cafe[cafe_idx, 0] + ab_cafe[cafe_idx, 1] * d["afternoon"].values # linear model

File ~\anaconda3\envs\pymc_env\Lib\site-packages\aesara\tensor\basic.py:2619, in stack(*tensors, *kwargs) 2617 dtype = aes.upcast([i.dtype for i in tensors]) 2618 return MakeVector(dtype)(tensors) -> 2619 return join(axis, [shape_padaxis(t, axis) for t in tensors])

File ~\anaconda3\envs\pymc_env\Lib\site-packages\aesara\tensor\basic.py:2619, in (.0) 2617 dtype = aes.upcast([i.dtype for i in tensors]) 2618 return MakeVector(dtype)(tensors) -> 2619 return join(axis, *[shape_padaxis(t, axis) for t in tensors])

File ~\anaconda3\envs\pymc_env\Lib\site-packages\aesara\tensor\shape.py:846, in shape_padaxis(t, axis) 824 def shape_padaxis(t, axis): 825 """Reshape t by inserting 1 at the dimension axis. 826 827 Examples (...) 844 845 """ --> 846 _t = at.as_tensor_variable(t) 848 ndim = _t.ndim + 1 849 if not -ndim <= axis < ndim:

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 equivalent TensorVariable. 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 a to a tensor variable.--------------------------------------------------------------------------- NotImplementedError Traceback (most recent call last) Cell In[15], line 12 9 a = pm.Normal("a", 5.0, 2.0) # prior for average intercept 10 b = pm.Normal("b", -1.0, 0.5) # prior for average slope 11 ab_cafe = pm.MvNormal( ---> 12 "ab_cafe", mu=at.stack([a, b]), chol=chol, shape=(N_cafes, 2) 13 ) # population of varying effects 14 # shape needs to be (N_cafes, 2) because we're getting back both a and b for each cafe 16 mu = ab_cafe[cafe_idx, 0] + ab_cafe[cafe_idx, 1] * d["afternoon"].values # linear model

File ~\anaconda3\envs\pymc_env\Lib\site-packages\aesara\tensor\basic.py:2619, in stack(*tensors, *kwargs) 2617 dtype = aes.upcast([i.dtype for i in tensors]) 2618 return MakeVector(dtype)(tensors) -> 2619 return join(axis, [shape_padaxis(t, axis) for t in tensors])

File ~\anaconda3\envs\pymc_env\Lib\site-packages\aesara\tensor\basic.py:2619, in (.0) 2617 dtype = aes.upcast([i.dtype for i in tensors]) 2618 return MakeVector(dtype)(tensors) -> 2619 return join(axis, *[shape_padaxis(t, axis) for t in tensors])

File ~\anaconda3\envs\pymc_env\Lib\site-packages\aesara\tensor\shape.py:846, in shape_padaxis(t, axis) 824 def shape_padaxis(t, axis): 825 """Reshape t by inserting 1 at the dimension axis. 826 827 Examples (...) 844 845 """ --> 846 _t = at.as_tensor_variable(t) 848 ndim = _t.ndim + 1 849 if not -ndim <= axis < ndim:

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 equivalent TensorVariable. 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 a to a tensor variable.

Chp16 code 16.2


KeyError Traceback (most recent call last) File ~\anaconda3\envs\pymc_env\Lib\site-packages\theano\tensor\type.py:254, in TensorType.dtype_specs(self) 253 try: --> 254 return { 255 'float16': (float, 'npy_float16', 'NPY_FLOAT16'), 256 'float32': (float, 'npy_float32', 'NPY_FLOAT32'), 257 'float64': (float, 'npy_float64', 'NPY_FLOAT64'), 258 'bool': (bool, 'npy_bool', 'NPY_BOOL'), 259 'uint8': (int, 'npy_uint8', 'NPY_UINT8'), 260 'int8': (int, 'npy_int8', 'NPY_INT8'), 261 'uint16': (int, 'npy_uint16', 'NPY_UINT16'), 262 'int16': (int, 'npy_int16', 'NPY_INT16'), 263 'uint32': (int, 'npy_uint32', 'NPY_UINT32'), 264 'int32': (int, 'npy_int32', 'NPY_INT32'), 265 'uint64': (int, 'npy_uint64', 'NPY_UINT64'), 266 'int64': (int, 'npy_int64', 'NPY_INT64'), 267 'complex128': (complex, 'theano_complex128', 'NPY_COMPLEX128'), 268 'complex64': (complex, 'theano_complex64', 'NPY_COMPLEX64') 269 }[self.dtype] 270 except KeyError:

KeyError: 'object'

During handling of the above exception, another exception occurred:

TypeError Traceback (most recent call last) File ~\anaconda3\envs\pymcenv\Lib\site-packages\theano\tensor\basic.py:246, in constant(x, name, ndim, dtype) 245 try: --> 246 ttype = TensorType(dtype=x.dtype, broadcastable=bcastable) 247 if not constant.enable:

File ~\anaconda3\envs\pymc_env\Lib\site-packages\theano\tensor\type.py:51, in TensorType.init(self, dtype, broadcastable, name, sparse_grad) 50 self.broadcastable = tuple(bool(b) for b in broadcastable) ---> 51 self.dtype_specs() # error checking is done there 52 self.name = name

File ~\anaconda3\envs\pymc_env\Lib\site-packages\theano\tensor\type.py:271, in TensorType.dtype_specs(self) 270 except KeyError: --> 271 raise TypeError("Unsupported dtype for %s: %s" 272 % (self.class.name, self.dtype))

TypeError: Unsupported dtype for TensorType: object

During handling of the above exception, another exception occurred:

TypeError Traceback (most recent call last) File ~\anaconda3\envs\pymc_env\Lib\site-packages\theano\tensor\basic.py:194, in as_tensor_variable(x, name, ndim) 193 try: --> 194 return constant(x, name=name, ndim=ndim) 195 except TypeError:

File ~\anaconda3\envs\pymc_env\Lib\site-packages\theano\tensor\basic.py:266, in constant(x, name, ndim, dtype) 265 except Exception: --> 266 raise TypeError("Could not convert %s to TensorType" % x, type(x))

TypeError: ('Could not convert p to TensorType', <class 'pytensor.tensor.var.TensorVariable'>)

During handling of the above exception, another exception occurred:

AsTensorError Traceback (most recent call last) Cell In[5], line 5 3 k = pm.Exponential("k", 0.5) 4 p = pm.Beta("p", alpha=2, beta=18) ----> 5 mu = pm.Deterministic("mu", pm.math.log(np.pi k tt.pow(p, 2) * tt.pow(d.h, 3))) 6 w = pm.Lognormal("w", mu, sigma, observed=d.w)

File ~\anaconda3\envs\pymc_env\Lib\site-packages\theano\gof\op.py:615, in PureOp.call(self, *inputs, *kwargs) 584 """ 585 Optional: return some or all output[s] of make_node. 586 (...) 612 613 """ 614 return_list = kwargs.pop('return_list', False) --> 615 node = self.make_node(inputs, **kwargs) 617 if config.compute_test_value != 'off': 618 run_perform = True

File ~\anaconda3\envs\pymc_env\Lib\site-packages\theano\tensor\elemwise.py:480, in Elemwise.make_node(self, inputs) 474 def make_node(self, inputs): 475 """ 476 If the inputs have different number of dimensions, their shape 477 is left-completed to the greatest number of dimensions with 1s 478 using DimShuffle. 479 """ --> 480 inputs = list(map(as_tensor_variable, inputs)) 481 out_dtypes, out_broadcastables, inputs = self.get_output_info( 482 DimShuffle, *inputs) 483 outputs = [TensorType(dtype=dtype, broadcastable=broadcastable)() 484 for dtype, broadcastable in izip(out_dtypes, 485 out_broadcastables)]

File ~\anaconda3\envs\pymc_env\Lib\site-packages\theano\tensor\basic.py:200, in as_tensor_variable(x, name, ndim) 198 except Exception: 199 str_x = repr(x) --> 200 raise AsTensorError("Cannot convert %s to TensorType" % str_x, type(x))

AsTensorError: ('Cannot convert p to TensorType', <class 'pytensor.tensor.var.TensorVariable'>)

Please feel free to let me know if you have any thoughts

ricardoV94 commented 1 year ago

You are mixing Theano with PyTensor. PyMC 5 uses PyTensor and all imports of Theano should be replaced by it