Debug mode in PyTensor

You can see the docs for debugging pytensor here. This includes how to set debug mode. The only extra thing you need to know is that since the function compilation happens inside sample, you need to set a context manager like this:

with pytensor.config.change_flags({'mode':'DEBUG_MODE'}):
    idata = pm.sample()

In general I don’t find this particularly helpful, though. If you read through the output carefully, you should find a more informative error. In your case I actually get a ValueError because sigma is negative, not a pytensor error.

I’ll spoil it and tell you that 99% of PyMC errors are just shape errors :slight_smile:

3 Likes