tensorFlow学习基础(一)之tensorboard的操作

import tensorflow as tf

#创建方程y = w * x + b

w = tf.Variable(2.0, dtype = tf.float32, name="W") #定义权重啦
b = tf.Variable(1.0, dtype = tf.float32, name="bais")
x = tf.placeholder(dtype = tf.float32, name="input")

with tf.name_scope("output"): #输出的空间命名
    y = w * x + b
#定义保存图的路径
path = "../log"

#初始化变量的值,不然会出错呀
init = tf.global_variables_initializer()

with tf.Session() as sess:
    sess.run(init) #实现初始化变量
    writer = tf.summary.FileWriter(path, sess.graph)  #得到的图保存自己制定的目录下
    res = sess.run(y, {x : 3.0})
    print("y = %s" % res)

然后打开我们的目录下会有相对应的文件夹
在这里插入图片描述
然后我们打开cmd 通过cd进入到与blog同级的目录下 执行:tensorboard --logdir=log
访问下面给出的地址得到:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_37982109/article/details/88653685
今日推荐