tensorflow - 使用 tf.data.TFRecordDataset 读取 TF2 摘要文件
问题描述
在 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))
推荐阅读
- javascript - 如何将表单与一个输入链接提交与两个链接
- html - 带箭头的垂直线
- android - Android (Chrome) 上带有初始屏幕的 PWA 无法在应用名称中显示特殊字符
- java - StorageService 在 GluonHQ 框架上出现错误 - 我该如何解决?
- wpf - WPF DockPanel MinHeight 用法
- javascript - JavaScript:连续调用多个异步函数的更好方法?
- firebase - Decoding managed protocol buffer datastore/firestore export by google with protoc
- reactjs - 如何在 React Redux 中全局设置 `forwardRef: true`?
- javascript - 为什么axios拦截器中不能设置cookies
- c# - 如果单击图像或文本,则仅单击自定义选项卡项