码迷,mamicode.com
首页 > 其他好文 > 详细

tensorflow- tf.Print

时间:2018-12-04 00:55:19      阅读:390      评论:0      收藏:0      [点我收藏+]

标签:printing   服务   bin   into   打印   python2   默认   前缀   ESS   

tf.Print

?

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

#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Thu Sep  6 10:16:37 2018
@author: myhaspl
"""
import tensorflow as tf

i=tf.constant(0)
res=tf.Print(i + 1, [i],"i:")
with tf.Session() as sess:
    print sess.run(res) 

i:[0]
1

输出tensor列表

这是一个标识OP(行为类似于tf.identity)打印计算数据的副作用。

注意:这个OP打印到标准错误。它目前不兼容JUJYTER notebook(打印到notebook服务器的输出,不进入notebook)。

Note:?This op prints to the standard error. It is not currently compatible with jupyter notebook (printing to the notebook?server‘s?output, not into the notebook).

参数:

input: 需要通过op计算的input
data: 当OP被计算时打印出来的张量的列表。
message: 一个字符串,错误消息的前缀。
first_n: 只记录 first_n次?数,负数总是日志,这是默认值。
summarize: 只打印每个张量的许多条目。如果没有,则每输入张量打印最多3个元素。
name: 操作的名称(可选)
返回:

一个?Tensor,和?input_内容和大小一样

tensorflow- tf.Print

标签:printing   服务   bin   into   打印   python2   默认   前缀   ESS   

原文地址:http://blog.51cto.com/13959448/2325568

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!