我对 tensorflow 很陌生,我尝试展示我的第一个 tensorboard。
我下载并执行了此处给出的示例的板子 https://www.tensorflow.org/versions/r0.7/how_tos/summaries_and_tensorboard/index.html
按照该方法,我的代码中有:
weights_hidden = tf.Variable(tf.truncated_normal([image_size * image_size, 1024]), name='weights_hidden')
_ = tf.histogram_summary('weights_hidden', weights_hidden)
当我运行会话时
with tf.Session(graph=graph) as session:
merged = tf.merge_all_summaries()
writer = tf.train.SummaryWriter("/tmp/test", session.graph_def)
tf.initialize_all_variables().run()
for step in range(num_steps):
summary_str, l, predictions = session.run(
[optimizer, loss, train_prediction], feed_dict=feed_dict)
if (step % 500 == 0):
writer.add_summary(summary_str, step)
进程崩溃并出现以下错误
Traceback (most recent call last):
File "/home/xxx/Desktop/xxx/xxx.py", line 108, in <module>
writer.add_summary(summary_str, step)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/summary_io.py", line 128, in add_summary
event = event_pb2.Event(wall_time=time.time(), summary=summary)
File "/usr/local/lib/python2.7/dist-packages/google/protobuf/internal/python_message.py", line 522, in init
_ReraiseTypeErrorWithFieldName(message_descriptor.name, field_name)
File "/usr/local/lib/python2.7/dist-packages/google/protobuf/internal/python_message.py", line 453, in _ReraiseTypeErrorWithFieldName
six.reraise(type(exc), exc, sys.exc_info()[2])
File "/usr/local/lib/python2.7/dist-packages/google/protobuf/internal/python_message.py", line 520, in init
copy.MergeFrom(new_val)
File "/usr/local/lib/python2.7/dist-packages/google/protobuf/internal/python_message.py", line 1237, in MergeFrom
"expected %s got %s." % (cls.__name__, type(msg).__name__))
TypeError: Parameter to MergeFrom() must be instance of same class: expected Summary got NoneType. for field Event.summary
我错过了什么?非常欢迎任何帮助/评论
非常感谢你的帮助
K。