相关疑难解决方法(0)

TensorFlow - 立即从TFRecords中读取所有示例?

您如何一次性阅读TFRecords中的所有示例?

我一直在使用tf.parse_single_example类似于fully_connected_reader示例中的方法read_and_decode中给出的代码来读出单个示例.但是,我想立即针对我的整个验证数据集运行网络,因此希望完全加载它们.

我不完全确定,但文档似乎建议我可以使用tf.parse_example而不是tf.parse_single_example一次加载整个TFRecords文件.我似乎无法让这个工作.我猜它与我如何指定功能有关,但我不确定在功能规范中如何说明有多个例子.

换句话说,我尝试使用类似的东西:

reader = tf.TFRecordReader()
_, serialized_example = reader.read(filename_queue)
features = tf.parse_example(serialized_example, features={
    'image_raw': tf.FixedLenFeature([], tf.string),
    'label': tf.FixedLenFeature([], tf.int64),
})
Run Code Online (Sandbox Code Playgroud)

不起作用,我认为这是因为这些功能不会同时出现多个例子(但同样,我不确定).[导致错误ValueError: Shape () must have rank 1]

这是一次读取所有记录的正确方法吗?如果是这样,我需要更改什么来实际读取记录?非常感谢!

python tensorflow tfrecord

31
推荐指数
4
解决办法
3万
查看次数

标签 统计

python ×1

tensorflow ×1

tfrecord ×1