如何编辑日志目录并保存?

时间:2019-05-22 16:20:32

标签: python tensorflow tensorboard

我有此代码,可以成功加载丢失信息。我想编辑此信息并再次保存,以便以后可以加载tensorboard进行显示,如何实现?

from tensorflow.python.summary import event_accumulator as ea

acc = ea.EventAccumulator("train")
acc.Reload()

# Print tags of contained entities, use these names to retrieve entities as below
print(acc.Tags())

xy_l2_loss = [(s.step, s.value) for s in acc.Scalars('seq2seq/loss/loss')]

print(xy_l2_loss)

1 个答案:

答案 0 :(得分:1)

假设您要将其存储在文件中:

import pickle
from tensorflow.python.summary import event_accumulator as ea

acc = ea.EventAccumulator("train")
acc.Reload()

# Print tags of contained entities, use these names to retrieve entities as below
print(acc.Tags())

xy_l2_loss = [(s.step, s.value) for s in acc.Scalars('seq2seq/loss/loss')]

print(xy_l2_loss)
xy_l2_loss = 'asdf'
#store data
with open('somefile.pkl', 'wb') as f:
    pickle.dump(xy_l2_loss, f)
#load data
with open('somefile.pkl', 'rb') as f:
    xy_l2_loss = pickle.load(f)