TensorFlow、TensorBoard:未找到标量数据
TensorFlow, TensorBoard: No scalar data was found
我正在研究如何操作 tensorboard。
我在这里看了演示:
https://www.tensorflow.org/code/tensorflow/examples/tutorials/mnist/mnist_with_summaries.py
它 运行 在我的笔记本电脑上运行良好。
其中大部分对我来说都很有意义。
于是,我写了一个简单的tensorflow demo:
# tensorboard_demo1.py
import tensorflow as tf
sess = tf.Session()
with tf.name_scope('scope1'):
y1 = tf.constant(22.9) * 1.1
tf.scalar_summary('y1 scalar_summary', y1)
train_writer = tf.train.SummaryWriter('/tmp/tb1',sess.graph)
print('Result:')
# Now I should run the compute graph:
print(sess.run(y1))
train_writer.close()
# done
好像运行还行吧
接下来我运行一个简单的shell命令:
tensorboard --log /tmp/tb1
它告诉我浏览 0.0.0.0:6006
我做到了。
网页告诉我:
未找到标量数据。
我如何增强我的演示,以便它记录张量板将显示给我的标量摘要?
您必须调用 train_writer.add_summary()
to add some data to the log. For example, one common pattern is to use tf.merge_all_summaries()
来创建一个张量,该张量隐含地合并来自当前图中创建的所有摘要的信息:
# Creates a TensorFlow tensor that includes information from all summaries
# defined in the current graph.
summary_t = tf.merge_all_summaries()
# Computes the current value of all summaries in the current graph.
summary_val = sess.run(summary_t)
# Writes the summary to the log.
train_writer.add_summary(summary_val)
我正在研究如何操作 tensorboard。
我在这里看了演示:
https://www.tensorflow.org/code/tensorflow/examples/tutorials/mnist/mnist_with_summaries.py
它 运行 在我的笔记本电脑上运行良好。
其中大部分对我来说都很有意义。
于是,我写了一个简单的tensorflow demo:
# tensorboard_demo1.py
import tensorflow as tf
sess = tf.Session()
with tf.name_scope('scope1'):
y1 = tf.constant(22.9) * 1.1
tf.scalar_summary('y1 scalar_summary', y1)
train_writer = tf.train.SummaryWriter('/tmp/tb1',sess.graph)
print('Result:')
# Now I should run the compute graph:
print(sess.run(y1))
train_writer.close()
# done
好像运行还行吧
接下来我运行一个简单的shell命令:
tensorboard --log /tmp/tb1
它告诉我浏览 0.0.0.0:6006
我做到了。
网页告诉我:
未找到标量数据。
我如何增强我的演示,以便它记录张量板将显示给我的标量摘要?
您必须调用 train_writer.add_summary()
to add some data to the log. For example, one common pattern is to use tf.merge_all_summaries()
来创建一个张量,该张量隐含地合并来自当前图中创建的所有摘要的信息:
# Creates a TensorFlow tensor that includes information from all summaries
# defined in the current graph.
summary_t = tf.merge_all_summaries()
# Computes the current value of all summaries in the current graph.
summary_val = sess.run(summary_t)
# Writes the summary to the log.
train_writer.add_summary(summary_val)