1 确认你已经将python/scripts添加至环境变量中 确认你已经安装好tensorflow
PS:如何安装tensorflow?
在python/Scripts目录下输入cmd进入命令行窗口
输入pip install tensorflow
等待几分钟后安装完成
然后测试tensorflow:
如果没有报错证明已经安装成功。
2将文件路径写到tensorboard.exe的路径中去,也就是Python/Scripts中(附带测试代码)
import tensorflow as tf
with tf.name_scope('score'):score = tf.Variable(36.0, name= "score")#用来显示标量信息tf.summary.scalar('score-e',score)
with tf.name_scope('factor'):factor = tf.Variable(10.0, name= "factor")tf.summary.scalar('factor-e',factor)
with tf.name_scope('sqart'):temp = tf.sqrt(score)tf.summary.scalar('temp-e',temp)
with tf.name_scope('new_score'):new_score = tf.multiply(factor, temp)tf.summary.scalar('new_score',new_score)
sess = tf.Session()
init = tf.global_variables_initializer()
sess.run(init)
result = sess.run(new_score)
summary_op = tf.summary.merge_all()
#文件路径为你的tensorboard.exe所在路径
writer = tf.summary.FileWriter("E:/python35/Scripts/logs_test/", sess.graph)
print(result)
sess.close()
执行上述代码,发现在python/scripts路径下生成了logs_test文件
3在Python/Scripts目录下输入cmd进入命令行窗口
输入tensorboard --logdir=E:/python35/Scripts/logs_test/
4复制命令行中的网址,打开Chrome浏览器,粘贴,回车
大功告成。