使用 tf.data.TFRecordDataset 读取 TF2 摘要文件

fis*_*ree 6 tensorflow tensorboard tensorflow2.0

在 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)`
Run Code Online (Sandbox Code Playgroud)

所以我想知道如何使用tf.data.TFRecordDataset(path)读取TF2生成的tfevent文件。

Ale*_*NON -1

我真的不知道你想要实现什么,但如果 TFEvent 文件是常规 TFRecord 文件,你可以通过这种方式使用新的 API。

event_files = tf.data.Dataset.list_files("./outputs/events.out.tfevents*")
serialized_examples = tf.data.TFRecordDataset(events_files)
for serialized_example in serialized_examples:
  ...
Run Code Online (Sandbox Code Playgroud)

希望这能有所帮助。

种类。