我无法对string_input_producer启用时代限制,但没有发生OutOfRange错误(请求的x,当前大小为0)。似乎并不重要,我有多少元素,总是有0。TensorFlow:如何在string_input_producer中使用'num_epochs'
这是我开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
如果我从它可以创建样本罚款string_input_producer删除num_epochs = 1。
我的输入管道:
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])
里面'read_binary_format',使用'try ...除了OutOfRange'构造来处理异常 –
什么是错误信息? –
FIFOQueue'_1_batch/fifo_queue'已关闭且元素不足(请求200,当前大小为0)。似乎并不重要,我有多少元素,总是有0。 – Lukeyb