首页 > 其他 > 详细

Tensorflow细节-Tensorboard可视化-简介

时间:2019-10-13 23:01:47      阅读:104      评论:0      收藏:0      [点我收藏+]

先搞点基础的

注意注意注意,这里虽然很基础,但是代码应注意:
1、从writer开始后边就错开了
2、writer后可以直接接writer.close,也就是说可以:

writer = tf.summary.FileWriter("./log", graph=g)
writer.close()
import tensorflow as tf

g = tf.Graph()
with g.as_default():
    input1 = tf.get_variable("input1", shape=[3], dtype=tf.float32, initializer=tf.constant_initializer([1.0, 2.0, 3.0]))
    input2 = tf.get_variable("input2", shape=[3], dtype=tf.float32, initializer=tf.constant_initializer([1.0, 2.0, 3.0]))
    with tf.name_scope("add_reault"):
        output = tf.add_n([input1, input2], name="add")

writer = tf.summary.FileWriter("./log", graph=g)
with tf.Session(graph=g) as sess:
    sess.run(tf.global_variables_initializer())
    print(sess.run(output))
writer.close()

对命名空间的操作

注意最后两个命名的方式
1、 tf.get_variable不受tf.name_scope的影响
2、倒数第二个的输出是a/Variable:0
3、tf.Variable()既受tf.variable_scope()的影响也受with tf.name_scope("a"):的影响

import tensorflow as tf

with tf.variable_scope("foo"):
    a = tf.get_variable("bar", [1])
    print(a.name)

with tf.variable_scope("bar"):
    b = tf.get_variable("bar", [1])
    print(b.name)

with tf.name_scope("a"):
    a = tf.Variable([1])
    print(a.name)
    a = tf.get_variable("b", [1])
    print(a.name)

with tf.variable_scope("b",):
    tf.get_variable("b", [1])

Tensorflow细节-Tensorboard可视化-简介

原文:https://www.cnblogs.com/liuboblog/p/11668626.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!