在 TF1 中,我可以使用 summary_iterator
阅读摘要文件。但是现在,它会抛出警告
WARNING:tensorflow: tf_record_iterator (from tensorflow.python.lib.io.tf_record) is deprecated and will be removed in a future version.
Instructions for updating:
Use eager execution and:
`tf.data.TFRecordDataset(path)`
所以我想知道如何使用
tf.data.TFRecordDataset(path)
读取 TF2 生成的 tfevent 文件。
最佳答案
实际上,这对我有用
from tensorflow.core.util import event_pb2
serialized_examples = tf.data.TFRecordDataset(path)
for serialized_example in serialized_examples:
event = event_pb2.Event.FromString(serialized_example.numpy())
for value in event.summary.value:
t = tf.make_ndarray(value.tensor)
print(value.tag, event.step, t, type(t))
关于tensorflow - 使用 tf.data.TFRecordDataset 读取 TF2 摘要文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58248787/