我训练了一个模型很长时间(200 000 次迭代)。在每次迭代中,我都通过 tf.summary.FileWriter()
类保存了大量数据,例如损失、准确度、权重等。是的,我知道:那是愚蠢的。结果,我生成了一个将近 50 GB 的巨大摘要。现在我想删除大部分信息并保留,比如说,每 50 行一行。这将使我能够节省大量硬盘空间并加快 tensorboard 可视化速度,同时不会对摘要的质量产生重大影响。有可能吗?
最佳答案
允许您读取事件文件(存储摘要的地方)的函数是 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()
关于python - 清理 tensorflow 摘要,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50566040/