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

标签 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)`

所以我想知道如何使用 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/

相关文章:

python - 'Tensor' 对象在 TF 2.0 的 tf.function 中没有属性 'numpy'

java - 将tensorflow keras LSTM模型转换为.tflite或任何工作格式

python - 如何在自定义 python 运算符 (tf.py_func) 中更新模型(变量)?

python - 使用 TF 数据集和 Eager 创建有状态计数器

Tensorflow - 数据集 API 中的字符串处理

python - 张量板出现两个一维图而不是一个二维图的问题

keras - Keras:如何将学习率输出到张量板上

python - 对于自定义 Python 代码,是否有替代 tf.py_function() 的方法?

python - 在 Tensorboard 中绘制各个层的梯度

python - 如何使用 TensorFlow 中的指定索引访问 3D 张量的元素?