def dbg_hook(hook, x): if not isinstance(x, TT.TensorVariable): x.out = theano.printing.Print(global_fn=hook)(x.out) return x else: return theano.printing.Print(global_fn=hook)(x)