Hi all,
I have been attempting to get the (gradient-less) black-box likelihood function to work. I followed this example here Using a “black box” likelihood function (numpy) — PyMC example gallery, and can get this code to run, but obtain the following error when trying to extend it to my problem:
Traceback (most recent call last):
File "/home/henney/.local/lib/python3.10/site-packages/pytensor/compile/function/types.py", line 970, in __call__
self.vm()
ValueError: Not enough dimensions on input.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/henney/Documents/Oxford/General_electrochemistry/heuristics/combined_heuristics_pmc3.py", line 215, in <module>
idata_mh = pm.sample(10000, tune=2000)
File "/home/henney/.local/lib/python3.10/site-packages/pymc/sampling/mcmc.py", line 619, in sample
model.check_start_vals(ip)
File "/home/henney/.local/lib/python3.10/site-packages/pymc/model.py", line 1781, in check_start_vals
initial_eval = self.point_logps(point=elem)
File "/home/henney/.local/lib/python3.10/site-packages/pymc/model.py", line 1816, in point_logps
self.compile_fn(factor_logps_fn)(point),
File "/home/henney/.local/lib/python3.10/site-packages/pymc/pytensorf.py", line 764, in __call__
return self.f(**state)
File "/home/henney/.local/lib/python3.10/site-packages/pytensor/compile/function/types.py", line 983, in __call__
raise_with_op(
File "/home/henney/.local/lib/python3.10/site-packages/pytensor/link/utils.py", line 535, in raise_with_op
raise exc_value.with_traceback(exc_trace)
File "/home/henney/.local/lib/python3.10/site-packages/pytensor/compile/function/types.py", line 970, in __call__
self.vm()
ValueError: Not enough dimensions on input.
Apply node that caused the error: Sum{acc_dtype=float64}(likelihood)
Toposort index: 16
Inputs types: [TensorType(float64, (?,))]
Inputs shapes: [()]
Inputs strides: [()]
Inputs values: [array(-966.97620582)]
Outputs clients: [['output']]
Backtrace when the node is created (use PyTensor flag traceback__limit=N to make it longer):
File "/home/henney/Documents/Oxford/General_electrochemistry/heuristics/combined_heuristics_pmc3.py", line 215, in <module>
idata_mh = pm.sample(10000, tune=2000)
File "/home/henney/.local/lib/python3.10/site-packages/pymc/sampling/mcmc.py", line 619, in sample
model.check_start_vals(ip)
File "/home/henney/.local/lib/python3.10/site-packages/pymc/model.py", line 1781, in check_start_vals
initial_eval = self.point_logps(point=elem)
File "/home/henney/.local/lib/python3.10/site-packages/pymc/model.py", line 1811, in point_logps
factor_logps_fn = [pt.sum(factor) for factor in self.logp(factors, sum=False)]
File "/home/henney/.local/lib/python3.10/site-packages/pymc/model.py", line 1811, in <listcomp>
factor_logps_fn = [pt.sum(factor) for factor in self.logp(factors, sum=False)]
I haven’t been able to recreate this error using in the simpler example code linked though. The only observation I have is that when I raise an error in the perform() function, the dimensions of the tensor are not empty, i.e.:
Toposort index: 15
Inputs types: [TensorType(float64, (14,))]
Inputs shapes: [(14,)]
Inputs strides: [(8,)]
Inputs values: ['not shown']
Outputs clients: [[Sum{acc_dtype=float64}(likelihood)]]
So I am mystified as to where this error is actually occurring. Any suggestions would be extremely welcome!