This code runs smoothly,
with pm.Model() as model_test:
slope_ = pm.Normal("slope", mu=0, sigma=1)
intercept_ = pm.Normal("intercept", mu = 3, sigma=1)
sigma_ = pm.HalfNormal("sigma", sigma = 1)
mu = slope_*x + intercept_
y_est = pm.Normal("y_est", mu=mu, sigma=sigma_, observed=y)
spc = pm.sample_prior_predictive(samples=100)
But this one raises an strange PyTensor error,
with pm.Model() as model_test:
slope_ = pm.Normal("slope", mu=0, sigma=1)
intercept_ = pm.Normal("intercept", mu = 3, sigma=1)
sigma_ = pm.HalfNormal("sigma", sigma = 1)
mu = slope_*x + intercept_
y_est = pm.Gamma("y_est", mu=mu, sigma=sigma_, observed=y)
spc = pm.sample_prior_predictive(samples=100)
The error:
in Function.call(self, *args, **kwargs) 968 try: 969 outputs = ( → 970 self.vm() 971 if output_subset is None 972 else self.vm(output_subset=output_subset) 973 ) 974 except Exception: in Op.make_py_thunk…rval(p, i, o, n, params) 539 @is_thunk_type 540 def rval( 541 p=p, i=node_input_storage, o=node_output_storage, n=node, params=None 542 ): → 543 r = p(n, [x[0] for x in i], o) 544 for o in node.outputs: File [~/miniconda3/envs/PyMC5_2/lib/python3.10/site-packages/pytensor/tensor/random/op.py:378]lib/python3.10/site-packages/pytensor/tensor/random/op.py:378), in RandomVariable.perform(self, node, inputs, outputs) 376 rng_var_out[0] = rng → 378 smpl_val = self.rng_fn(rng, *(args + [size])) 380 if ( 381 not isinstance(smpl_val, np.ndarray) 382 or str(smpl_val.dtype) != out_var.type.dtype
…
Inputs values: [Generator(PCG64) at 0x7F2C51526DC0, array([87]), array(11), ‘not shown’, ‘not shown’] Outputs clients: [[‘output’], [‘output’]]
HINT: Re-running with most PyTensor optimizations disabled could provide a back-trace showing when this node was created. This can be done by setting the PyTensor flag ‘optimizer=fast_compile’. If that does not work, PyTensor optimizations can be disabled with ‘optimizer=None’.
HINT: Use the PyTensor flag exception_verbosity=high
for a debug print-out and storage map footprint of this Apply node.