jupyter notebook 下tensorboard 使用

例: 

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

# 清除 default graph 和不断增加的节点
tf.reset_default_graph()

# logdir 改为自己机器上的合适路径
logdir = '/Users/mac/jupyter_project/log'

# 定义一个简单的计算图,实现向量加法的操作
input1 = tf.constant([1.0,2.0,3.0],name="input1")
input2 = tf.Variable(tf.random_uniform([3]),name="input2")
output = tf.add_n([input1,input2],name="add")

# 生成一个写日志的writer,并将当前的TensorFlow计算图写入日志
writer = tf.summary.FileWriter(logdir,tf.get_default_graph())
writer.close()

运行后,打开终端,转到log路径

cd /jupyter_project/log

我的默认当前目录是/Users/mac,所以直接转到jupyter_project下

输入 ls,后会得出文件夹中的文件

 转到 anaconda 虚拟环境下,输入

python3 -m tensorboard.main --logdir=/Users/mac/jupyter_project/log

在浏览器输入 http://localhost:6006/,即可打开tensorboard

发布了16 篇原创文章 · 获赞 0 · 访问量 447

猜你喜欢

转载自blog.csdn.net/weixin_43951831/article/details/105136062