如果没有一个string_input_producer错误(请求x,当前大小为0),我无法在OutOfRange上启用时间限制。我请求多少元素似乎并不重要,总是有0可用。
下面是我的FileQueue构建器:
def get_queue(base_directory):
files = [f for f in os.listdir(base_directory) if f.endswith('.bin')]
shuffle(files)
file = [os.path.join(base_directory, files[0])]
fileQueue = tf.train.string_input_producer(file, shuffle=False, num_epochs=1)
return fileQueue如果我从num_epochs=1中删除string_input_producer,它可以很好地创建示例。
我的输入管道:
def input_pipeline(instructions, fileQueue):
example, label, feature_name_list = read_binary_format(fileQueue, instructions)
num_preprocess_threads = 16
capacity = 20
example, label = tf.train.batch(
[example, label],
batch_size=50000, # set the batch size way bigger so we always return the full amount of samples from the file
allow_smaller_final_batch=True,
capacity=capacity,
num_threads=num_preprocess_threads)
return example, label最后是我的会议:
with tf.Session(graph=tf.Graph()) as sess:
train_inst_set = sf.DeserializationInstructions.from_filename(os.path.join(input_dir, "Train/config.json"))
fileQueue = sf.get_queue(os.path.join(input_dir, "Train"))
features_train, labels_train = sf.input_pipeline(train_inst_set, fileQueue)
sess.run(tf.global_variables_initializer())
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord, sess=sess)
train_feature_batch, train_label_batch = sess.run([features_train, labels_train])发布于 2017-09-06 23:07:24
这个问题是由以下原因引起的:第1045期
无论出于什么原因,tf.global_variable_initialiser并不会初始化所有变量。您也需要初始化局部变量。
添加
sess.run(tf.group(tf.global_variables_initializer(), tf.local_variables_initializer()))敬你的会议。
https://stackoverflow.com/questions/46071998
复制相似问题