Is there a way to get tensorflow tf.Print output to appear in Jupyter Notebook output

后端 未结 5 732
日久生厌
日久生厌 2020-12-09 10:47

I\'m using the tf.Print op in a Jupyter notebook. It works as required, but will only print the output to the console, without printing in the notebook. Is there any way to

5条回答
  •  爱一瞬间的悲伤
    2020-12-09 11:43

    You can check the terminal where you launched the jupyter notebook to see the message.

    import tensorflow as tf
    
    tf.InteractiveSession()
    
    a = tf.constant(1)
    b = tf.constant(2)
    
    opt = a + b
    opt = tf.Print(opt, [opt], message="1 + 2 = ")
    
    opt.eval()
    

    In the terminal, I can see:

    2018-01-02 23:38:07.691808: I tensorflow/core/kernels/logging_ops.cc:79] 1 + 2 = [3]
    

提交回复
热议问题