Я пытаюсь получить очень простой читатель TFRecord для работы, но безрезультатно. (Я могу заставить писателя работать отлично).Невозможно получить простой читатель TFRecord для работы
От this github repo, есть reader.py
файл, и это выглядит так:
import tensorflow as tf
import numpy as np
import time
from PIL import Image
def read_and_decode(filename_queue):
reader = tf.TFRecordReader()
_, serialized_example = reader.read(filename_queue)
features = tf.parse_single_example(
serialized_example,
# Defaults are not specified since both keys are required.
features={
'height':tf.FixedLenFeature([], tf.int64),
'image_raw': tf.FixedLenFeature([], tf.string),
'label': tf.FixedLenFeature([], tf.int64)
})
image = tf.decode_raw(features['image_raw'], tf.uint8)
image = tf.reshape(image,[478, 717, 3])
image = tf.cast(image, tf.float32) * (1./255) - 0.5
label = tf.cast(features['label'], tf.int32)
return image
'''
Pointers: Remember to run init_op
tf.reshape may not be the ideal way.
'''
def run():
with tf.Graph().as_default():
filename_queue = tf.train.string_input_producer(["sample.tfrecords"],num_epochs=1)
images = read_and_decode(filename_queue)
image_shape = tf.shape(images)
init_op = tf.initialize_all_variables()
with tf.Session() as sess:
sess.run(init_op)
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
img = sess.run([images])
coord.request_stop()
coord.join(threads)
run()
Проблема заключается в том, что, когда я бегу, я получаю следующее сообщение об ошибке:
Итак, я в последний раз ударяю головой об этом. Я не уверен, что делать, или даже почему это не работает. Это похоже на простой пример, который не должен иметь проблемы. Я использую TF010.
Благодаря
Мне любопытно, какую версию TF вы использовали, когда вы написали этот пример репо изначально? – Spacey
Первый коммит был в марте 2016 года. Вероятно, от 0.7.0 до 0.8.0, если вы ссылаетесь на историю выпуска https://github.com/tensorflow/tensorflow/releases?after=v0.10.0rc0. – jkschin
Поскольку я немного новичок в TensorFlow, позвольте мне спросить вас, что заставило вас подозревать, что это проблема с tf.initialize_all_variables() из загадочного сообщения об ошибке? – Spacey