清理 tensorflow 摘要

Gia*_*chi 1 python tensorflow tensorboard

我已经训练了一个模型很长时间(200 000 次迭代)。在每次迭代中,我都通过类保存了大量数据,例如损失、准确度、权重等tf.summary.FileWriter()。是的,我知道:那是愚蠢的。结果,我生成了一个将近 50 GB 的巨大摘要。现在我想删除大部分信息并保留每 50 行一行。这将允许我节省大量硬盘空间并加速张量板可视化,同时不会对摘要的质量产生重大影响。有可能这样做吗?

P-G*_*-Gn 5

允许您读取事件文件(存储摘要的位置)的函数是tf.train.summary_iterator. 你可以尝试这样的事情:

import tensorflow as tf

tfevents_filepath = path_to_existing_event_file
tfevents_folder_new = path_to_new_event_file_folder

writer = tf.summary.FileWriter(tfevents_folder_new)
for e in tf.train.summary_iterator(tfevents_filepath):
  if e.step == 0 or e.step % 50 == 0: # or any other criterion but make sure
                                      # you keep events from step 0
    writer.add_event(e)
writer.close()
Run Code Online (Sandbox Code Playgroud)