tf打印调试信息的方法 Debugging operation tf.Print

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

Prints a list of tensors. This is an identity op with the side effect of printing data when evaluating.

Args:

 

  • input_: A tensor passed through this op.这个参数是要处理的数据(可以称为处理前数据)
  • data: A list of tensors to print out when op is evaluated.这个参数(是一个列表)是上面的参数经过处理或者计算之后,想要打印的内容
  • message: A string, prefix of the error message.是一个字符串,接在data输出之前组成要打印的全部内容
  • first_n: Only log(记录) first_n number of times. Negative numbers log always; this is the default.
  • summarize: Only print this many entries of each tensor.参数summarize默认为3,只打印3个参数
  • name: A name for the operation (optional).

Returns:

Same tensor as input_.

 举例子

 bgr = tf.Print(bgr, [tf.shape(bgr)], message='Shape of input image: ', summarize=4, first_n=1)
实际上打印出来的是Shape of input image:(224,224,3)

为什么要用这个函数?

tensorflow是通过先建图再运行的方式进行运行,这就使得我们写在图建立过程中的输出语句在图运行的时候并不能得到执行,从而使得调试困难. 我们想在运行过程中,对训练的一些变量进行追踪和打印,对一些错误进行输出分析

详细例子可以参考 tf打印调试信息方法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值