tensorflow tf.打印不在Jupyter中打印任何内容

tensorflow tf.打印不在Jupyter中打印任何内容,tensorflow,Tensorflow,正在使用jupyter在Python/tensorflow1.0中尝试调试语句,但没有从tf.Print打印任何输出 在下面代码的培训过程中,sess.run应该已经评估了db1张量,并打印了未发生的输出 但是,db1.eval处于求值阶段,正在打印整个张量X,并输出消息X: def combine_inputs(X): db1=tf.Print(X,[X],message='X:') return (tf.matmul(X, W) + b,db1) <<training cod

正在使用jupyter在Python/tensorflow1.0中尝试调试语句,但没有从tf.Print打印任何输出

在下面代码的培训过程中,sess.run应该已经评估了db1张量,并打印了未发生的输出 但是,db1.eval处于求值阶段,正在打印整个张量X,并输出消息X:

def combine_inputs(X):
 db1=tf.Print(X,[X],message='X:')
 return (tf.matmul(X, W) + b,db1)
<<training code>>
_,summary=sess.run([train_op,merged_summaries])
## merged_summaries tensor triggers combine_inputs function. There are  
## other tensor functions/coding in between , not giving entire code to keep   
## it simple; code works as expected except tf.Print

<<evaluate code>>
print(db1.eval())

Confused on following

a) Why tf.Print is not printing during sess.run during training?

b) Why explicit db1.eval is necessary , expected tf.Print to trigger with  
sess.run. If eval is required , could copy tensor X in my code to db1 
and evaluate it with out tf.Print. Correct?
试着回答下面的问题。建议实现内存_util或预定义函数。因为学员无法理解为什么tf.Print在我的场景中不起作用

如果有人遇到类似问题,请协助。谢谢


根据文档,tf.Print从1.1版开始按标准错误打印,它与jupyter笔记本不兼容。这就是为什么你看不到任何输出

请点击此处:

您可以查看启动jupyter笔记本电脑的终端以查看消息

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()
在终端,我可以看到:

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