2
我只是絆了這個問題: TensorFlow - Read all examples from a TFRecords at once?Tensorflow:使用tf.parse_example爲JPEG批次
首先回答問題的建議使用tf.parse_example而不是解析單的例子,因爲這似乎是更快。但提供的代碼並不完整,我不知道如何使用它。如果我批處理,然後使用parse_example我會得到一批功能。這意味着我需要解壓該批次才能解碼jpegs?從答案中的代碼是:
reader = tf.TFRecordReader()
_, serialized_example = reader.read(filename_queue)
features = tf.parse_single_example(serialized_example, features={
image/center': tf.VarLenFeature(tf.string),
})
image = features['image/center']
image_decoded = tf.image.decode_jpeg(image.values[0], channels=3)
return image_decoded
,並建議切換到:
batch = tf.train.batch([serialized_example], num_examples, capacity=num_examples)
parsed_examples = tf.parse_example(batch, feature_spec)
但如何我現在可以解碼那些parsed_examples?
當您按原樣執行時會發生什麼?根據[tf.decode_raw文檔](https://www.tensorflow.org/versions/r0.11/api_docs/python/io_ops.html#decode_raw)它應該解碼整批示例。 – sygi
對不起,我複製了另一個問題的代碼,沒有意識到這是一個不同的小問題。我使用jpegs ...我將編輯這個問題! tf.image.decode_jpeg不支持我認爲的批處理 –