New to PyMC - I’m working through the tutorial on reinforced learning. My package versions are: Python (3.8.5), PyMC (5.6.1), PyTensor (2.12.3), Numpy (1.24.4), Arviz (0.15.1), Cython (0.29.33).I am getting a Value Error while running pytensor_llik_td = pytensor.function( inputs=[alpha, beta], outputs=neg_loglike, on_unused_input="ignore" )
in section “Estimating the learning parameter via PyMC”. Can someone help me figure out what to do?
Specifically, here are my errors:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
File ~/.pyenv/versions/3.8.5/lib/python3.8/site-packages/pytensor/link/vm.py:1243, in VMLinker.make_all(self, profiler, input_storage, output_storage, storage_map)
1239 # no-recycling is done at each VM.__call__ So there is
1240 # no need to cause duplicate c code by passing
1241 # no_recycling here.
1242 thunks.append(
-> 1243 node.op.make_thunk(node, storage_map, compute_map, [], impl=impl)
1244 )
1245 linker_make_thunk_time[node] = time.perf_counter() - thunk_start
File ~/.pyenv/versions/3.8.5/lib/python3.8/site-packages/pytensor/scan/op.py:1512, in Scan.make_thunk(self, node, storage_map, compute_map, no_recycling, impl)
1510 raise MissingGXX
-> 1512 from . import scan_perform_ext
1514 cython_mintaps = np.asarray(self.mintaps, dtype="int32")
File ~/.pyenv/versions/3.8.5/lib/python3.8/site-packages/pytensor/scan/scan_perform_ext.py:8
1 """
2
3 To update the `Scan` Cython code you must
(...)
6
7 """
----> 8 from pytensor.scan.scan_perform import get_version, perform # noqa: F401, E402
11 version = 0.326 # must match constant returned in function get_version()
File ~/.pyenv/versions/3.8.5/lib/python3.8/site-packages/pytensor/scan/scan_perform.pyx:1, in init pytensor.scan.scan_perform()
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
Cell In[31], line 36
33 logp_actions = logp_actions[pt.arange(actions_.shape[0] - 1), actions_[1:]]
34 neg_loglike = -pt.sum(logp_actions)
---> 36 pytensor_llik_td = pytensor.function(
37 inputs=[alpha, beta], outputs=neg_loglike, on_unused_input="ignore"
38 )
39 result = pytensor_llik_td(true_alpha, true_beta)
40 float(result)
File ~/.pyenv/versions/3.8.5/lib/python3.8/site-packages/pytensor/compile/function/__init__.py:315, in function(inputs, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input)
309 fn = orig_function(
310 inputs, outputs, mode=mode, accept_inplace=accept_inplace, name=name
311 )
312 else:
313 # note: pfunc will also call orig_function -- orig_function is
314 # a choke point that all compilation must pass through
--> 315 fn = pfunc(
316 params=inputs,
317 outputs=outputs,
318 mode=mode,
319 updates=updates,
320 givens=givens,
321 no_default_updates=no_default_updates,
322 accept_inplace=accept_inplace,
323 name=name,
324 rebuild_strict=rebuild_strict,
325 allow_input_downcast=allow_input_downcast,
326 on_unused_input=on_unused_input,
327 profile=profile,
328 output_keys=output_keys,
329 )
330 return fn
File ~/.pyenv/versions/3.8.5/lib/python3.8/site-packages/pytensor/compile/function/pfunc.py:367, in pfunc(params, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input, output_keys, fgraph)
353 profile = ProfileStats(message=profile)
355 inputs, cloned_outputs = construct_pfunc_ins_and_outs(
356 params,
357 outputs,
(...)
364 fgraph=fgraph,
365 )
--> 367 return orig_function(
368 inputs,
369 cloned_outputs,
370 mode,
371 accept_inplace=accept_inplace,
372 name=name,
373 profile=profile,
374 on_unused_input=on_unused_input,
375 output_keys=output_keys,
376 fgraph=fgraph,
377 )
File ~/.pyenv/versions/3.8.5/lib/python3.8/site-packages/pytensor/compile/function/types.py:1756, in orig_function(inputs, outputs, mode, accept_inplace, name, profile, on_unused_input, output_keys, fgraph)
1744 m = Maker(
1745 inputs,
1746 outputs,
(...)
1753 fgraph=fgraph,
1754 )
1755 with config.change_flags(compute_test_value="off"):
-> 1756 fn = m.create(defaults)
1757 finally:
1758 t2 = time.perf_counter()
File ~/.pyenv/versions/3.8.5/lib/python3.8/site-packages/pytensor/compile/function/types.py:1649, in FunctionMaker.create(self, input_storage, storage_map)
1646 start_import_time = pytensor.link.c.cmodule.import_time
1648 with config.change_flags(traceback__limit=config.traceback__compile_limit):
-> 1649 _fn, _i, _o = self.linker.make_thunk(
1650 input_storage=input_storage_lists, storage_map=storage_map
1651 )
1653 end_linker = time.perf_counter()
1655 linker_time = end_linker - start_linker
File ~/.pyenv/versions/3.8.5/lib/python3.8/site-packages/pytensor/link/basic.py:254, in LocalLinker.make_thunk(self, input_storage, output_storage, storage_map, **kwargs)
247 def make_thunk(
248 self,
249 input_storage: Optional["InputStorageType"] = None,
(...)
252 **kwargs,
253 ) -> Tuple["BasicThunkType", "InputStorageType", "OutputStorageType"]:
--> 254 return self.make_all(
255 input_storage=input_storage,
256 output_storage=output_storage,
257 storage_map=storage_map,
258 )[:3]
File ~/.pyenv/versions/3.8.5/lib/python3.8/site-packages/pytensor/link/vm.py:1252, in VMLinker.make_all(self, profiler, input_storage, output_storage, storage_map)
1250 thunks[-1].lazy = False
1251 except Exception:
-> 1252 raise_with_op(fgraph, node)
1254 t1 = time.perf_counter()
1256 if self.profile:
File ~/.pyenv/versions/3.8.5/lib/python3.8/site-packages/pytensor/link/utils.py:535, in raise_with_op(fgraph, node, thunk, exc_info, storage_map)
530 warnings.warn(
531 f"{exc_type} error does not allow us to add an extra error message"
532 )
533 # Some exception need extra parameter in inputs. So forget the
534 # extra long error message in that case.
--> 535 raise exc_value.with_traceback(exc_trace)
File ~/.pyenv/versions/3.8.5/lib/python3.8/site-packages/pytensor/link/vm.py:1243, in VMLinker.make_all(self, profiler, input_storage, output_storage, storage_map)
1238 thunk_start = time.perf_counter()
1239 # no-recycling is done at each VM.__call__ So there is
1240 # no need to cause duplicate c code by passing
1241 # no_recycling here.
1242 thunks.append(
-> 1243 node.op.make_thunk(node, storage_map, compute_map, [], impl=impl)
1244 )
1245 linker_make_thunk_time[node] = time.perf_counter() - thunk_start
1246 if not hasattr(thunks[-1], "lazy"):
1247 # We don't want all ops maker to think about lazy Ops.
1248 # So if they didn't specify that its lazy or not, it isn't.
1249 # If this member isn't present, it will crash later.
File ~/.pyenv/versions/3.8.5/lib/python3.8/site-packages/pytensor/scan/op.py:1512, in Scan.make_thunk(self, node, storage_map, compute_map, no_recycling, impl)
1509 if impl == "py":
1510 raise MissingGXX
-> 1512 from . import scan_perform_ext
1514 cython_mintaps = np.asarray(self.mintaps, dtype="int32")
1516 n_outs = self.info.n_mit_mot + self.info.n_mit_sot + self.info.n_sit_sot
File ~/.pyenv/versions/3.8.5/lib/python3.8/site-packages/pytensor/scan/scan_perform_ext.py:8
1 """
2
3 To update the `Scan` Cython code you must
(...)
6
7 """
----> 8 from pytensor.scan.scan_perform import get_version, perform # noqa: F401, E402
11 version = 0.326 # must match constant returned in function get_version()
12 assert version == get_version(), (
13 "Invalid extension, check the installation process, "
14 "could be problem with .pyx file or Cython ext build process."
15 )
File ~/.pyenv/versions/3.8.5/lib/python3.8/site-packages/pytensor/scan/scan_perform.pyx:1, in init pytensor.scan.scan_perform()
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
Apply node that caused the error: Scan{scan_fn, while_loop=False, inplace=all}(150, [1 0 0 0 0 ... 1 1
1 1], [0 1 1 1 0 ... 1 0
1 1], SetSubtensor{:stop}.0, alpha)
Toposort index: 3
Inputs types: [TensorType(int64, shape=()), TensorType(int32, shape=(150,)), TensorType(int32, shape=(150,)), TensorType(float64, shape=(150, 2)), TensorType(float64, shape=())]
HINT: Use a linker other than the C linker to print the inputs' shapes and strides.
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.