如何解析单个 TFrecord 文件 [英] How to parse a single TFrecord file

查看:36
本文介绍了如何解析单个 TFrecord 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

读取 tfrecords:

To read tfrecords:

reader = tf.TFRecordReader()
_, serialized_example = reader.read(filename_queue)
features = tf.parse_single_example(...)

TFRecordReader 从文件队列中读取示例.但是如何从特定文件中同步读取单个示例(无需队列).喜欢

TFRecordReader reads examples from a file queue. But how to read a single example from a particular file synchronically(without a queue). like

file_buf = tf.read_file(filename)
serialized_example = get_train_example(file_buf)
features = tf.parse_single_example(...)

如何实现get_train_example函数

推荐答案

不确定这是否正是您要找的,但您可以在没有队列的情况下这样做:

Not sure if this exactly what you're looking for, but you can do it this way without a queue:

tf_record = "path/to/my.tfrecord"
e = tf.python_io.tf_record_iterator(tf_record).next()
single_example = tf.parse_single_example(e, features=features)

这篇关于如何解析单个 TFrecord 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆