使用tf.print()打印tensor内容

时间:2018-08-11 19:13:00   收藏:0   阅读:1708

使用tf.Print()打印tensor内容,这是tensorflow中调试bug的一个手段,例子如下所示:

import tensorflow as tf

a = tf.Variable(tf.random_normal([3, 3, 1, 64], stddev=0.1))
a = tf.Print(a, [a], "a: ",summarize=9)
init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init)
sess.run(a)

输出结果

技术分享图片

tf.Print()函数参数为:

Print(
    input_,
    data,
    message=None,
    first_n=None,
    summarize=None,
    name=None
)

参数:

返回:

该操作将返回与 input_ 相同的张量。

原文:https://www.cnblogs.com/shixisheng/p/9460614.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!