tf_event_file读取
使用tensorboard
可以对events.out.tfevents.
进行可视化,如需读取
其内loss或acc等曲线进行custom处理的话,则需使用读取函数将其数值读取出来,读取函数如下:
import os
import json
import tensorflow as tf
def get_loss_from_tfevent_file(tfevent_filename):
"""
:param tfevent_filename: the name of one tfevent file
:return: loss (list)
"""
loss_val_list = []
for event in tf.train.summary_iterator(tfevent_filename):
for value in event.summary.value:
# print(value.tag)
if value.HasField('simple_value'):
if value.tag == "loss":
# print(value.simple_value)
loss_val_list.append(value.simple_value)
return loss_val_list
函数输入为tfevent文件名
,输出为loss
取值列表。注意如需读取其他变量值,可以修改函数中value.tag
项。
转载:https://blog.csdn.net/u010103202/article/details/101293090
查看评论