Pymc4_using: idata_extend()

Thank you for your very prompt reply.

The PYMC and Arviz versions I am running are:

  • Runing on PyMC v4.4.0
  • Runing on Arviz v0.14.0

The full error Message is:

ValueError                                Traceback (most recent call last)
~\anaconda_new\lib\site-packages\aesara\link\vm.py in __call__(self)
    413                 ):
--> 414                     thunk()
    415                     for old_s in old_storage:

~\anaconda_new\lib\site-packages\aesara\graph\op.py in rval(p, i, o, n, params)
    542             ):
--> 543                 r = p(n, [x[0] for x in i], o)
    544                 for o in node.outputs:

~\anaconda_new\lib\site-packages\aesara\tensor\random\op.py in perform(self, node, inputs, outputs)
    367 
--> 368         smpl_val = self.rng_fn(rng, *(args + [size]))
    369 

~\anaconda_new\lib\site-packages\aesara\tensor\random\basic.py in rng_fn(cls, *args, **kwargs)
     54         size = args[-1]
---> 55         res = cls.rng_fn_scipy(*args, **kwargs)
     56 

~\anaconda_new\lib\site-packages\aesara\tensor\random\basic.py in rng_fn_scipy(cls, rng, loc, scale, size)
    336         """
--> 337         return stats.halfnorm.rvs(loc, scale, random_state=rng, size=size)
    338 

~\anaconda_new\lib\site-packages\scipy\stats\_distn_infrastructure.py in rvs(self, *args, **kwds)
   1065                        "documentation for details.")
-> 1066             raise ValueError(message)
   1067 

ValueError: Domain error in arguments. The `scale` parameter must be positive for all distributions, and many distributions have restrictions on shape parameters. Please see the `scipy.stats.halfnorm` documentation for details.

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_30492\2263873921.py in <module>
      1 with model_h:
----> 2     idata_h.extend(pm.sample_prior_predictive())
      3     idata_h.extend(pm.sample_posterior_predictive(idata_h))

~\anaconda_new\lib\site-packages\pymc\sampling\forward.py in sample_prior_predictive(samples, model, var_names, random_seed, return_inferencedata, idata_kwargs, compile_kwargs)
    422     # All model variables have a name, but mypy does not know this
    423     _log.info(f"Sampling: {list(sorted(volatile_basic_rvs, key=lambda var: var.name))}")  # type: ignore
--> 424     values = zip(*(sampler_fn() for i in range(samples)))
    425 
    426     data = {k: np.stack(v) for k, v in zip(names, values)}

~\anaconda_new\lib\site-packages\pymc\sampling\forward.py in <genexpr>(.0)
    422     # All model variables have a name, but mypy does not know this
    423     _log.info(f"Sampling: {list(sorted(volatile_basic_rvs, key=lambda var: var.name))}")  # type: ignore
--> 424     values = zip(*(sampler_fn() for i in range(samples)))
    425 
    426     data = {k: np.stack(v) for k, v in zip(names, values)}

~\anaconda_new\lib\site-packages\aesara\compile\function\types.py in __call__(self, *args, **kwargs)
    969         try:
    970             outputs = (
--> 971                 self.vm()
    972                 if output_subset is None
    973                 else self.vm(output_subset=output_subset)

~\anaconda_new\lib\site-packages\aesara\link\vm.py in __call__(self)
    416                         old_s[0] = None
    417             except Exception:
--> 418                 raise_with_op(self.fgraph, node, thunk)
    419 
    420         return self.perform_updates()

~\anaconda_new\lib\site-packages\aesara\link\utils.py in raise_with_op(fgraph, node, thunk, exc_info, storage_map)
    532         # Some exception need extra parameter in inputs. So forget the
    533         # extra long error message in that case.
--> 534     raise exc_value.with_traceback(exc_trace)
    535 
    536 

~\anaconda_new\lib\site-packages\aesara\link\vm.py in __call__(self)
    412                     self.thunks, self.nodes, self.post_thunk_clear, fillvalue=()
    413                 ):
--> 414                     thunk()
    415                     for old_s in old_storage:
    416                         old_s[0] = None

~\anaconda_new\lib\site-packages\aesara\graph\op.py in rval(p, i, o, n, params)
    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:
    545                     compute_map[o][0] = True

~\anaconda_new\lib\site-packages\aesara\tensor\random\op.py in perform(self, node, inputs, outputs)
    366         rng_var_out[0] = rng
    367 
--> 368         smpl_val = self.rng_fn(rng, *(args + [size]))
    369 
    370         if (

~\anaconda_new\lib\site-packages\aesara\tensor\random\basic.py in rng_fn(cls, *args, **kwargs)
     53     def rng_fn(cls, *args, **kwargs):
     54         size = args[-1]
---> 55         res = cls.rng_fn_scipy(*args, **kwargs)
     56 
     57         if np.ndim(res) == 0:

~\anaconda_new\lib\site-packages\aesara\tensor\random\basic.py in rng_fn_scipy(cls, rng, loc, scale, size)
    335 
    336         """
--> 337         return stats.halfnorm.rvs(loc, scale, random_state=rng, size=size)
    338 
    339 

~\anaconda_new\lib\site-packages\scipy\stats\_distn_infrastructure.py in rvs(self, *args, **kwds)
   1064                        f"Please see the `scipy.stats.{self.name}` "
   1065                        "documentation for details.")
-> 1066             raise ValueError(message)
   1067 
   1068         if np.all(scale == 0):

ValueError: Domain error in arguments. The `scale` parameter must be positive for all distributions, and many distributions have restrictions on shape parameters. Please see the `scipy.stats.halfnorm` documentation for details.
Apply node that caused the error: halfnormal_rv{0, (0, 0), floatX, True}(RandomGeneratorSharedVariable(<Generator(PCG64) at 0x23FA90F5900>), TensorConstant{(1,) of 4}, TensorConstant{11}, TensorConstant{0.0}, sigma_mean)
Toposort index: 11
Inputs types: [RandomGeneratorType, TensorType(int64, (1,)), TensorType(int64, ()), TensorType(float32, ()), TensorType(float64, ())]
Inputs shapes: ['No shapes', (1,), (), (), ()]
Inputs strides: ['No strides', (8,), (), (), ()]
Inputs values: [Generator(PCG64) at 0x23FA90F5900, array([4], dtype=int64), array(11, dtype=int64), array(0., dtype=float32), array(-14.39499803)]
Outputs clients: [['output'], ['output', Subtensor{uint8}(sigma, ScalarConstant{3}), Subtensor{uint8}(sigma, ScalarConstant{2}), Subtensor{uint8}(sigma, ScalarConstant{1}), Subtensor{uint8}(sigma, ScalarConstant{0})]]

HINT: Re-running with most Aesara optimizations disabled could provide a back-trace showing when this node was created. This can be done by setting the Aesara flag 'optimizer=fast_compile'. If that does not work, Aesara optimizations can be disabled with 'optimizer=None'.
HINT: Use the Aesara flag `exception_verbosity=high` for a debug print-out and storage map footprint of this Apply node.

Hope, that the above helps to the resolve the problem. Thank you for devoting you time and expertise to resolving this newbie coding problem. Declan