TensorBoard 显示没有找到图像数据

TensorBoard shows No image data was found

我已经使用 TensorFlow 为 MNIST 实现了神经网络。我想在 TensorBoard 上显示结果。下面是我已经实现的 TensorBoard 的屏幕截图。但是 IMAGES 页面显示“未找到图像数据”。

这里应该显示什么信息?我应该忽略它吗?

代码

import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data

tf.reset_default_graph()
mnist = input_data.read_data_sets('data', one_hot=True)

batch_size = 100
learning_rate = 0.5
training_epochs = 5
logs_path = "C:/tmp/mlp"

with tf.name_scope('input'):
    x = tf.placeholder(tf.float32, shape=[None, 784], name="x-input")
    y_ = tf.placeholder(tf.float32, shape=[None, 10], name="y-input")
with tf.name_scope("weights"):
    W = tf.Variable(tf.zeros([784, 10]))
with tf.name_scope("biases"):
    b = tf.Variable(tf.zeros([10]))
with tf.name_scope("softmax"):
    y = tf.nn.softmax(tf.matmul(x, W) + b)
with tf.name_scope('cross_entropy'):
    cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))
with tf.name_scope('train'):
    train_op = tf.train.GradientDescentOptimizer(learning_rate).minimize(cross_entropy)
with tf.name_scope('Accuracy'):
    correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))
    accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
tf.summary.scalar("cost", cross_entropy)
tf.summary.scalar("accuracy", accuracy)
summary_op = tf.summary.merge_all()
with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    summary_writer = tf.summary.FileWriter("C:/tmp/mlp", sess.graph)
    for epoch in range(training_epochs):
        batch_count = int(mnist.train.num_examples / batch_size)
        for i in range(batch_count):
            batch_x, batch_y = mnist.train.next_batch(batch_size)
            _, summary = sess.run([train_op, summary_op], feed_dict={x: batch_x, y_: batch_y})
            summary_writer.add_summary(summary, epoch * batch_count + i)
        if epoch % 5 == 0:
            print("Epoch: ", epoch)
    print("Accuracy: ", accuracy.eval(feed_dict={x: mnist.test.images, y_: mnist.test.labels}))
    print("done")

忽略它们,因为您确实保存了任何 tf.summary.image 摘要,Tensorboard 不会在此选项卡中显示任何内容;

代码中唯一引用汇总操作的行是:

tf.summary.scalar("cost", cross_entropy)
tf.summary.scalar("accuracy", accuracy)

这些行创建 2 个标量摘要(并将创建的摘要添加到包含每个已定义摘要的默认集合中)。

您没有定义任何图像摘要(tf.summmary.image),因此张量板中的选项卡将为空。