Skip to content
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)