从TensorBoard TFEvent文件导入数据?

2024-04-28 15:36:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我用TensorFlow中的不同图形运行了几个培训课程。我设置的摘要在培训和验证中显示了有趣的结果。现在,我想把我保存在摘要日志中的数据,进行一些统计分析和一般绘图,并以不同的方式查看摘要数据。有没有现成的方法可以方便地访问这些数据?

更具体地说,是否有内置的方法将TFEvent记录读回Python?

如果没有简单的方法,请TensorFlow states that all its file formats are protobuf files。根据我对protobufs(这是有限的)的理解,我认为如果我有TFEvent协议规范,就能够提取这些数据。有什么简单的方法可以知道吗?非常感谢。


Tags: 数据方法图形绘图thattensorflow方式记录
3条回答

作为Fabriziosays,TensorBoard是可视化摘要日志内容的一个很好的工具。但是,如果要执行自定义分析,可以使用^{}函数循环日志中的所有^{}^{}协议缓冲区:

for summary in tf.train.summary_iterator("/path/to/log/file"):
    # Perform custom processing in here.

更新以下内容:

from tensorflow.python.summary.summary_iterator import summary_iterator

您需要导入它,默认情况下该模块级别当前未导入。在2.0.0-rc2上

要读取TFEvent,您可以获得一个Python迭代器,该迭代器生成事件协议缓冲区。

# This example supposes that the events file contains summaries with a
# summary value tag 'loss'.  These could have been added by calling
# `add_summary()`, passing the output of a scalar summary op created with
# with: `tf.scalar_summary(['loss'], loss_tensor)`.
for e in tf.train.summary_iterator(path_to_events_file):
    for v in e.summary.value:
        if v.tag == 'loss' or v.tag == 'accuracy':
            print(v.simple_value)

更多信息:summary_iterator

您只需使用:

tensorboard --inspect --event_file=myevents.out

或者,如果要筛选图表中事件的特定子集:

tensorboard --inspect --event_file=myevents.out --tag=loss

如果你想创造更多的定制,你可以挖掘

/tensorflow/python/summary/event_file_inspector.py 

了解如何解析事件文件。

相关问题 更多 >