Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draw and eval fails for packed_chol returned by LKJCholeskyCov #5565

Closed
fonnesbeck opened this issue Mar 7, 2022 · 1 comment
Closed

draw and eval fails for packed_chol returned by LKJCholeskyCov #5565

fonnesbeck opened this issue Mar 7, 2022 · 1 comment

Comments

@fonnesbeck
Copy link
Member

fonnesbeck commented Mar 7, 2022

Specifying a LKJCholeskyCov with compute_corr=False returns a packed_chol

with pm.Model() as m:
    packed_L = pm.LKJCholeskyCov("packed_L", n=2, eta=2.0, sd_dist=pm.Exponential.dist(1.0), compute_corr=False)

however, attempting to evaluate this variable or draw from it fails:

>>> packed_L.eval()

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py:969, in Function.__call__(self, *args, **kwargs)
    [967](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=966) try:
    [968](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=967)     outputs = (
--> [969](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=968)         self.fn()
    [970](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=969)         if output_subset is None
    [971](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=970)         else self.fn(output_subset=output_subset)
    [972](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=971)     )
    [973](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=972) except Exception:

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/op.py:508, in Op.make_py_thunk.<locals>.rval(p, i, o, n)
    [507](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/op.py?line=506) def rval(p=p, i=node_input_storage, o=node_output_storage, n=node):
--> [508](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/op.py?line=507)     r = p(n, [x[0] for x in i], o)
    [509](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/op.py?line=508)     for o in node.outputs:

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py:382, in RandomVariable.perform(self, node, inputs, outputs)
    [380](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=379) rng_var_out[0] = rng
--> [382](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=381) smpl_val = self.rng_fn(rng, *(args + [size]))
    [384](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=383) if (
    [385](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=384)     not isinstance(smpl_val, np.ndarray)
    [386](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=385)     or str(smpl_val.dtype) != out_var.type.dtype
    [387](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=386) ):

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/distributions/multivariate.py:1161, in _LKJCholeskyCovRV.rng_fn(self, rng, n, eta, D, size)
   [1159](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/distributions/multivariate.py?line=1158) C = LKJCorrRV._random_corr_matrix(rng, n, eta, flat_size)
-> [1161](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/distributions/multivariate.py?line=1160) D = D.reshape(flat_size, n)
   [1162](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/distributions/multivariate.py?line=1161) C *= D[..., :, np.newaxis] * D[..., np.newaxis, :]

ValueError: cannot reshape array of size [1](vscode-notebook-cell://wsl%2Bdebian/home/fonnesbeck/pymc-examples/examples/case_studies/LKJ.ipynb#ch0000009vscode-remote?line=0) into shape (1,2)

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
/home/fonnesbeck/pymc-examples/examples/case_studies/LKJ.ipynb Cell 10' in <module>
----> 1 packed_L.eval()

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/basic.py:553, in Variable.eval(self, inputs_to_values)
    [550](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/basic.py?line=549)     self._fn_cache[inputs] = function(inputs, self)
    [551](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/basic.py?line=550) args = [inputs_to_values[param] for param in inputs]
--> [553](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/basic.py?line=552) rval = self._fn_cache[inputs](*args)
    [555](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/basic.py?line=554) return rval

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py:982, in Function.__call__(self, *args, **kwargs)
    [980](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=979)     if hasattr(self.fn, "thunks"):
    [981](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=980)         thunk = self.fn.thunks[self.fn.position_of_error]
--> [982](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=981)     raise_with_op(
    [983](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=982)         self.maker.fgraph,
    [984](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=983)         node=self.fn.nodes[self.fn.position_of_error],
    [985](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=984)         thunk=thunk,
    [986](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=985)         storage_map=getattr(self.fn, "storage_map", None),
    [987](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=986)     )
    [988](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=987) else:
    [989](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=988)     # old-style linkers raise their own exceptions
    [990](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=989)     raise

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/link/utils.py:525, in raise_with_op(fgraph, node, thunk, exc_info, storage_map)
    [520](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/link/utils.py?line=519)     warnings.warn(
    [521](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/link/utils.py?line=520)         f"{exc_type} error does not allow us to add an extra error message"
    [522](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/link/utils.py?line=521)     )
    [523](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/link/utils.py?line=522)     # Some exception need extra parameter in inputs. So forget the
    [524](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/link/utils.py?line=523)     # extra long error message in that case.
--> [525](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/link/utils.py?line=524) raise exc_value.with_traceback(exc_trace)

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py:969, in Function.__call__(self, *args, **kwargs)
    [966](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=965) t0_fn = time.time()
    [967](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=966) try:
    [968](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=967)     outputs = (
--> [969](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=968)         self.fn()
    [970](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=969)         if output_subset is None
    [971](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=970)         else self.fn(output_subset=output_subset)
    [972](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=971)     )
    [973](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=972) except Exception:
    [974](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=973)     restore_defaults()

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/op.py:508, in Op.make_py_thunk.<locals>.rval(p, i, o, n)
    [507](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/op.py?line=506) def rval(p=p, i=node_input_storage, o=node_output_storage, n=node):
--> [508](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/op.py?line=507)     r = p(n, [x[0] for x in i], o)
    [509](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/op.py?line=508)     for o in node.outputs:
    [510](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/op.py?line=509)         compute_map[o][0] = True

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py:382, in RandomVariable.perform(self, node, inputs, outputs)
    [378](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=377)     rng = copy(rng)
    [380](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=379) rng_var_out[0] = rng
--> [382](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=381) smpl_val = self.rng_fn(rng, *(args + [size]))
    [384](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=383) if (
    [385](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=384)     not isinstance(smpl_val, np.ndarray)
    [386](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=385)     or str(smpl_val.dtype) != out_var.type.dtype
    [387](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=386) ):
    [388](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=387)     smpl_val = _asarray(smpl_val, dtype=out_var.type.dtype)

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/distributions/multivariate.py:1161, in _LKJCholeskyCovRV.rng_fn(self, rng, n, eta, D, size)
   [1157](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/distributions/multivariate.py?line=1156)     flat_size = np.prod(size)
   [1159](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/distributions/multivariate.py?line=1158) C = LKJCorrRV._random_corr_matrix(rng, n, eta, flat_size)
-> [1161](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/distributions/multivariate.py?line=1160) D = D.reshape(flat_size, n)
   [1162](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/distributions/multivariate.py?line=1161) C *= D[..., :, np.newaxis] * D[..., np.newaxis, :]
   [1164](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/distributions/multivariate.py?line=1163) tril_idx = np.tril_indices(n, k=0)

ValueError: cannot reshape array of size 1 into shape (1,2)
Apply node that caused the error: _lkjcholeskycov_rv{1, (0, 0, 1), floatX, True}(RandomStateSharedVariable(<RandomState(MT19937) at 0x7F4725B68040>), TensorConstant{[]}, TensorConstant{11}, TensorConstant{2}, TensorConstant{2.0}, exponential_rv{0, (0,), floatX, False}.out)
Toposort index: 1
Inputs types: [RandomStateType, TensorType(int64, (0,)), TensorType(int64, ()), TensorType(int32, ()), TensorType(float64, ()), TensorType(float64, ())]
Inputs shapes: ['No shapes', (0,), (), (), (), ()]
Inputs strides: ['No strides', (8,), (), (), (), ()]
Inputs values: [RandomState(MT19937) at 0x7F4725B68040, array([], dtype=int64), array(11), array(2, dtype=int32), array(2.), array(0.3401816)]
Outputs clients: [['output'], ['output']]

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.
>>> pm.draw(packed_L, draws=10)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py:969, in Function.__call__(self, *args, **kwargs)
    [967](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=966) try:
    [968](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=967)     outputs = (
--> [969](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=968)         self.fn()
    [970](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=969)         if output_subset is None
    [971](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=970)         else self.fn(output_subset=output_subset)
    [972](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=971)     )
    [973](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=972) except Exception:

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/op.py:508, in Op.make_py_thunk.<locals>.rval(p, i, o, n)
    [507](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/op.py?line=506) def rval(p=p, i=node_input_storage, o=node_output_storage, n=node):
--> [508](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/op.py?line=507)     r = p(n, [x[0] for x in i], o)
    [509](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/op.py?line=508)     for o in node.outputs:

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py:382, in RandomVariable.perform(self, node, inputs, outputs)
    [380](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=379) rng_var_out[0] = rng
--> [382](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=381) smpl_val = self.rng_fn(rng, *(args + [size]))
    [384](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=383) if (
    [385](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=384)     not isinstance(smpl_val, np.ndarray)
    [386](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=385)     or str(smpl_val.dtype) != out_var.type.dtype
    [387](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=386) ):

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/distributions/multivariate.py:1161, in _LKJCholeskyCovRV.rng_fn(self, rng, n, eta, D, size)
   [1159](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/distributions/multivariate.py?line=1158) C = LKJCorrRV._random_corr_matrix(rng, n, eta, flat_size)
-> [1161](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/distributions/multivariate.py?line=1160) D = D.reshape(flat_size, n)
   [1162](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/distributions/multivariate.py?line=1161) C *= D[..., :, np.newaxis] * D[..., np.newaxis, :]

ValueError: cannot reshape array of size [1](vscode-notebook-cell://wsl%2Bdebian/home/fonnesbeck/pymc-examples/examples/case_studies/LKJ.ipynb#ch0000009vscode-remote?line=0) into shape (1,2)

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
/home/fonnesbeck/pymc-examples/examples/case_studies/LKJ.ipynb Cell 10' in <module>
----> 1 pm.draw(packed_L, draws=10)

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/sampling.py:2175, in draw(vars, draws, mode, **kwargs)
   [2173](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/sampling.py?line=2172) if not isinstance(vars, (list, tuple)):
   [2174](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/sampling.py?line=2173)     drawn_values = (draw_fn() for _ in range(draws))
-> [2175](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/sampling.py?line=2174)     return np.stack(drawn_values)
   [2177](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/sampling.py?line=2176) # Multiple variable output
   [2178](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/sampling.py?line=2177) drawn_values = zip(*(draw_fn() for _ in range(draws)))

File <__array_function__ internals>:180, in stack(*args, **kwargs)

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/numpy/core/shape_base.py:420, in stack(arrays, axis, out)
    [416](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/numpy/core/shape_base.py?line=415) if not overrides.ARRAY_FUNCTION_ENABLED:
    [417](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/numpy/core/shape_base.py?line=416)     # raise warning if necessary
    [418](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/numpy/core/shape_base.py?line=417)     _arrays_for_stack_dispatcher(arrays, stacklevel=2)
--> [420](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/numpy/core/shape_base.py?line=419) arrays = [asanyarray(arr) for arr in arrays]
    [421](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/numpy/core/shape_base.py?line=420) if not arrays:
    [422](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/numpy/core/shape_base.py?line=421)     raise ValueError('need at least one array to stack')

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/numpy/core/shape_base.py:420, in <listcomp>(.0)
    [416](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/numpy/core/shape_base.py?line=415) if not overrides.ARRAY_FUNCTION_ENABLED:
    [417](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/numpy/core/shape_base.py?line=416)     # raise warning if necessary
    [418](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/numpy/core/shape_base.py?line=417)     _arrays_for_stack_dispatcher(arrays, stacklevel=2)
--> [420](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/numpy/core/shape_base.py?line=419) arrays = [asanyarray(arr) for arr in arrays]
    [421](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/numpy/core/shape_base.py?line=420) if not arrays:
    [422](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/numpy/core/shape_base.py?line=421)     raise ValueError('need at least one array to stack')

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/sampling.py:2174, in <genexpr>(.0)
   [2172](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/sampling.py?line=2171) # Single variable output
   [2173](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/sampling.py?line=2172) if not isinstance(vars, (list, tuple)):
-> [2174](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/sampling.py?line=2173)     drawn_values = (draw_fn() for _ in range(draws))
   [2175](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/sampling.py?line=2174)     return np.stack(drawn_values)
   [2177](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/sampling.py?line=2176) # Multiple variable output

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py:982, in Function.__call__(self, *args, **kwargs)
    [980](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=979)     if hasattr(self.fn, "thunks"):
    [981](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=980)         thunk = self.fn.thunks[self.fn.position_of_error]
--> [982](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=981)     raise_with_op(
    [983](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=982)         self.maker.fgraph,
    [984](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=983)         node=self.fn.nodes[self.fn.position_of_error],
    [985](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=984)         thunk=thunk,
    [986](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=985)         storage_map=getattr(self.fn, "storage_map", None),
    [987](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=986)     )
    [988](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=987) else:
    [989](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=988)     # old-style linkers raise their own exceptions
    [990](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=989)     raise

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/link/utils.py:525, in raise_with_op(fgraph, node, thunk, exc_info, storage_map)
    [520](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/link/utils.py?line=519)     warnings.warn(
    [521](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/link/utils.py?line=520)         f"{exc_type} error does not allow us to add an extra error message"
    [522](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/link/utils.py?line=521)     )
    [523](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/link/utils.py?line=522)     # Some exception need extra parameter in inputs. So forget the
    [524](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/link/utils.py?line=523)     # extra long error message in that case.
--> [525](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/link/utils.py?line=524) raise exc_value.with_traceback(exc_trace)

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py:969, in Function.__call__(self, *args, **kwargs)
    [966](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=965) t0_fn = time.time()
    [967](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=966) try:
    [968](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=967)     outputs = (
--> [969](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=968)         self.fn()
    [970](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=969)         if output_subset is None
    [971](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=970)         else self.fn(output_subset=output_subset)
    [972](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=971)     )
    [973](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=972) except Exception:
    [974](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py?line=973)     restore_defaults()

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/op.py:508, in Op.make_py_thunk.<locals>.rval(p, i, o, n)
    [507](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/op.py?line=506) def rval(p=p, i=node_input_storage, o=node_output_storage, n=node):
--> [508](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/op.py?line=507)     r = p(n, [x[0] for x in i], o)
    [509](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/op.py?line=508)     for o in node.outputs:
    [510](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/graph/op.py?line=509)         compute_map[o][0] = True

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py:382, in RandomVariable.perform(self, node, inputs, outputs)
    [378](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=377)     rng = copy(rng)
    [380](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=379) rng_var_out[0] = rng
--> [382](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=381) smpl_val = self.rng_fn(rng, *(args + [size]))
    [384](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=383) if (
    [385](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=384)     not isinstance(smpl_val, np.ndarray)
    [386](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=385)     or str(smpl_val.dtype) != out_var.type.dtype
    [387](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=386) ):
    [388](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/tensor/random/op.py?line=387)     smpl_val = _asarray(smpl_val, dtype=out_var.type.dtype)

File ~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/distributions/multivariate.py:1161, in _LKJCholeskyCovRV.rng_fn(self, rng, n, eta, D, size)
   [1157](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/distributions/multivariate.py?line=1156)     flat_size = np.prod(size)
   [1159](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/distributions/multivariate.py?line=1158) C = LKJCorrRV._random_corr_matrix(rng, n, eta, flat_size)
-> [1161](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/distributions/multivariate.py?line=1160) D = D.reshape(flat_size, n)
   [1162](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/distributions/multivariate.py?line=1161) C *= D[..., :, np.newaxis] * D[..., np.newaxis, :]
   [1164](file:///~/miniforge3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/distributions/multivariate.py?line=1163) tril_idx = np.tril_indices(n, k=0)

ValueError: cannot reshape array of size 1 into shape (1,2)
Apply node that caused the error: _lkjcholeskycov_rv{1, (0, 0, 1), floatX, True}(RandomStateSharedVariable(<RandomState(MT19937) at 0x7F4725B68040>), TensorConstant{[]}, TensorConstant{11}, TensorConstant{2}, TensorConstant{2.0}, exponential_rv{0, (0,), floatX, True}.out)
Toposort index: 1
Inputs types: [RandomStateType, TensorType(int64, (0,)), TensorType(int64, ()), TensorType(int32, ()), TensorType(float64, ()), TensorType(float64, ())]
Inputs shapes: ['No shapes', (0,), (), (), (), ()]
Inputs strides: ['No strides', (8,), (), (), (), ()]
Inputs values: [RandomState(MT19937) at 0x7F4725B68040, array([], dtype=int64), array(11), array(2, dtype=int32), array(2.), array(0.36022404)]
Outputs clients: [['output'], ['output']]

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.

Similarly, using compute_corr=True and returning the tuple of outputs results in the same error when trying to evaluate or draw from any of the returned components. The exception is also raised when sampling with pm.sample.

Versions and main components

  • PyMC/PyMC3 Version: 4.0.0b2
  • Aesara/Theano Version: 2.4.0
  • Python Version: 3.9.9
  • Operating system: Debian
  • How did you install PyMC/PyMC3: build from source
@fonnesbeck
Copy link
Member Author

NVM, same issue as #5441

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant