我有Tensorboard数据,并希望它下载所有csv文件背后的数据,但我找不到从官方的文档任何东西。在StackOverflow中,我只发现了这个有7年历史的问题,它也是关于TensorFlow的,而我正在使用PyTorch。
我们可以手动完成这个操作,就像我们在屏幕截图中看到的那样,手动有一个选项。我想知道我们是否可以通过代码做到这一点,还是不可能?因为我有很多数据要处理。
发布于 2022-02-23 16:44:53
在这个脚本的帮助下,下面是最短的工作代码,它获取dataframe
中的所有数据,然后您就可以继续播放了。
import traceback
import pandas as pd
from tensorboard.backend.event_processing.event_accumulator import EventAccumulator
# Extraction function
def tflog2pandas(path):
runlog_data = pd.DataFrame({"metric": [], "value": [], "step": []})
try:
event_acc = EventAccumulator(path)
event_acc.Reload()
tags = event_acc.Tags()["scalars"]
for tag in tags:
event_list = event_acc.Scalars(tag)
values = list(map(lambda x: x.value, event_list))
step = list(map(lambda x: x.step, event_list))
r = {"metric": [tag] * len(step), "value": values, "step": step}
r = pd.DataFrame(r)
runlog_data = pd.concat([runlog_data, r])
# Dirty catch of DataLossError
except Exception:
print("Event file possibly corrupt: {}".format(path))
traceback.print_exc()
return runlog_data
path="Run1" #folderpath
df=tflog2pandas(path)
#df=df[(df.metric != 'params/lr')&(df.metric != 'params/mm')&(df.metric != 'train/loss')] #delete the mentioned rows
df.to_csv("output.csv")
https://stackoverflow.com/questions/71239557
复制相似问题