Use of tensorboard under jupyter notebook

Example: 

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()

After running, open the terminal and go to the log path

cd /jupyter_project/log

My default current directory is / Users / mac, so go directly to jupyter_project

Type ls and you will find the files in the folder

 Go to the anaconda virtual environment, enter

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

Enter http: // localhost: 6006 / in the browser to open tensorboard

Published 16 original articles · praised 0 · visits 447

Guess you like

Origin blog.csdn.net/weixin_43951831/article/details/105136062