Closed
Description
Applying the pm.distributions.transforms.ordered
fails when applied to more than one dimension
Minimum working example
import pymc as pm
import numpy as np
COORDS = {'question': np.arange(10),
'thresholds': np.arange(4)}
with pm.Model(coords=COORDS) as model:
kappa = pm.Normal('kappa',
mu=[-3, -1, 1, 2],
sigma=1,
dims=['question', 'thresholds'],
transform=pm.distributions.transforms.ordered)
model.point_logps()
Traceback
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
~/opt/miniconda3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py in __call__(self, *args, **kwargs)
963 outputs = (
--> 964 self.fn()
965 if output_subset is None
ValueError: Input dimension mismatch. (input[2].shape[1] = 4, input[4].shape[1] = 10)
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
/var/folders/3d/p29f9frn6d3c3gnfq2bxbd1c0000gn/T/ipykernel_31128/1701730019.py in <module>
----> 1 model.point_logps()
~/opt/miniconda3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/model.py in point_logps(self, point, round_vals)
1726 for factor, factor_logp in zip(
1727 factors,
-> 1728 self.compile_fn(factor_logps_fn)(point),
1729 )
1730 }
~/opt/miniconda3/envs/pymc-dev-py39/lib/python3.9/site-packages/pymc/model.py in __call__(self, state)
1825
1826 def __call__(self, state):
-> 1827 return self.f(**state)
1828
1829
~/opt/miniconda3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py in __call__(self, *args, **kwargs)
975 if hasattr(self.fn, "thunks"):
976 thunk = self.fn.thunks[self.fn.position_of_error]
--> 977 raise_with_op(
978 self.maker.fgraph,
979 node=self.fn.nodes[self.fn.position_of_error],
~/opt/miniconda3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/link/utils.py in raise_with_op(fgraph, node, thunk, exc_info, storage_map)
536 # Some exception need extra parameter in inputs. So forget the
537 # extra long error message in that case.
--> 538 raise exc_value.with_traceback(exc_trace)
539
540
~/opt/miniconda3/envs/pymc-dev-py39/lib/python3.9/site-packages/aesara/compile/function/types.py in __call__(self, *args, **kwargs)
962 try:
963 outputs = (
--> 964 self.fn()
965 if output_subset is None
966 else self.fn(output_subset=output_subset)
ValueError: Input dimension mismatch. (input[2].shape[1] = 4, input[4].shape[1] = 10)
Apply node that caused the error: Elemwise{Composite{(i0 + (i1 * sqr((i2 - i3))) + i4)}}[(0, 2)](TensorConstant{(1, 1) of ..5332046727}, TensorConstant{(1, 1) of -0.5}, kappa_ordered___ordered, TensorConstant{[[-3 -1 1 2]]}, InplaceDimShuffle{x,0}.0)
Toposort index: 11
Inputs types: [TensorType(float64, (1, 1)), TensorType(float64, (1, 1)), TensorType(float64, (None, None)), TensorType(int64, (1, 4)), TensorType(float64, (1, None))]
Inputs shapes: [(1, 1), (1, 1), (10, 4), (1, 4), (1, 10)]
Inputs strides: [(8, 8), (8, 8), (32, 8), (32, 8), (80, 8)]
Inputs values: [array([[-0.91893853]]), array([[-0.5]]), 'not shown', array([[-3, -1, 1, 2]]), 'not shown']
Outputs clients: [[Sum{acc_dtype=float64}(kappa_ordered___logprob)]]
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.
Versions and main components
Python implementation: CPython
Python version : 3.9.9
IPython version : 7.31.0
pymc : 4.0.0b5
aesara: 2.5.1
Compiler : Clang 11.1.0
OS : Darwin
Release : 21.4.0
Machine : x86_64
Processor : i386
CPU cores : 8
Architecture: 64bit