Skip to content

Added a helper function to print intermediate values #7146

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
10 changes: 10 additions & 0 deletions pymc/model/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from pytensor.compile import DeepCopyOp, get_mode
from pytensor.compile.sharedvalue import SharedVariable
from pytensor.graph.basic import Constant, Variable, graph_inputs
from pytensor.printing import Print
from pytensor.scalar import Cast
from pytensor.tensor.elemwise import Elemwise
from pytensor.tensor.random.op import RandomVariable
Expand Down Expand Up @@ -2245,3 +2246,12 @@ def normal_logp(value, mu, sigma):
)

return var


def print_value(var, name=None):
"""Print value of variable when it is computed during sampling.
This is likely to affect sampling performance.
"""
if name is None:
name = var.name
return Print(name)(var)