如何在Tensorflow中添加张量元素作为标量摘要?

问题描述 投票:0回答:1

我有10个元素的张量。如何将每个元素添加为标量摘要,最好显示在Tensorboard中的同一图表上?

tensorflow tensorboard
1个回答
0
投票

您可以访问它们,就好像张量是一个numpy数组:tensor[i,j],其中i和j是元素所在的索引(在elemnt是向量的情况下为tensor[i])。

然后将它们添加到摘要中:

for i in tensor:
    tf.summary.scalar("tensor"+ str(i), tensor[i], collections= "tensor")

合并它们:merged_summary = tf.summary.merge_all(key=['tensor'])运行它:merged = sess.run(merged_summary, feed_dict={...})并将其写入文件编写者:writer.add_summary(merged, epoch)

为了能够在同一个图中合并它们,我只知道一种制动最后一次合并的方法:对张量中的每个值使用不同的文件编写器。不过,以下链接可能有用:

https://www.quora.com/How-do-you-plot-training-and-validation-loss-on-the-same-graph-using-TensorFlow%E2%80%99s-TensorBoard

https://github.com/tensorflow/tensorflow/issues/7089

https://github.com/tensorflow/tensorboard/issues/300

https://github.com/tensorflow/tensorboard/pull/664

© www.soinside.com 2019 - 2024. All rights reserved.