AttributeError:“列表”对象没有属性“值”

时间:2019-08-25 06:45:39

标签: tensorboard

我将在张量板上可视化Cost函数,但是当我运行以下代码时....我收到此错误: AttributeError:“列表”对象没有属性“值”

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    logs_path = 'log_simple_stats_5_layers_relu_softmax'
    writer = tf.summary.FileWriter(logs_path,graph=tf.get_default_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_step, summary_op],feed_dict={XX: batch_x,Y_: batch_y})
            writer.add_summary(summary,epoch * batch_count + i)
        print ("Epoch: ", epoch)

    print ("Accuracy: ", accuracy.eval(feed_dict={XX: mnist.test.images,Y_: mnist.test.labels}))
    print ("done")



error is :
AttributeError                            Traceback (most recent call last)
<ipython-input-89-979d49859de1> in <module>
     10             batch_x, batch_y = mnist.train.next_batch(batch_size)
     11             summary = sess.run([train_step, summary_op],feed_dict={XX: batch_x,Y_: batch_y})
---> 12             writer.add_summary(summary,epoch * batch_count + i)
     13         print ("Epoch: ", epoch)
     14 

~\Anaconda3\lib\site-packages\tensorflow\python\summary\writer\writer.py in add_summary(self, summary, global_step)
    125     # to save space - we just store the metadata on the first value with a
    126     # specific tag.
--> 127     for value in summary.value:
    128       if not value.metadata:
    129         continue

AttributeError: 'list' object has no attribute 'value'

0 个答案:

没有答案