tf.Print(input, data, message=None, first_n=None, summarize=None, name=None)
最低要求两个输入,input和data,input是需要打印的变量的名字,data要求是一个list,里面包含要打印的内容。
- message是需要输出的错误信息
- first_n指只记录前n次
- summarize是对每个tensor只打印的条目数量,如果是None,对于每个输入tensor只打印3个元素
- name是op的名字
a code example
x=tf.constant([2,3,4,5])
x=tf.Print(x, [x, x.shape, 'test', x], message='Debug message:', summarize=100)
with tf.Session() as sess:
sess.run(x)
# Debug message:[2 3 4 5][4][test][2 3 4 5]