1
我正在測試tensoprflow隊列系統,我有一個簡單的使用隊列處理輸入的tensorflow程序。示例程序的代碼是Tensorflow在使用隊列的sess.run調用時凍結
import tensorflow as tf
import numpy as np
def model(example_batch):
dense1 = tf.layers.dense(inputs=example_batch, units=64, activation=tf.nn.relu)
dense2 = tf.layers.dense(inputs=dense1, units=2)
return dense2
x_input_data = tf.random_normal([1024, 16], mean=0, stddev=1)
q = tf.FIFOQueue(capacity=1, dtypes=tf.float32, shapes=[1024, 16])
enqueue_op = q.enqueue(x_input_data)
numberOfThreads = 1
qr = tf.train.QueueRunner(q, [enqueue_op] * numberOfThreads)
tf.train.add_queue_runner(qr)
input = q.dequeue()
sess = tf.Session()
sess.run(tf.global_variables_initializer())
# Start input enqueue threads.
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(sess=sess, coord=coord)
example_batch = tf.train.batch([input], batch_size=1, num_threads=numberOfThreads, capacity=1, enqueue_many=False)
for step in range(100):
print ("step")
#sess.run(input)
p = sess.run(model(example_batch))
coord.request_stop()
coord.join(threads)
sess.close()
的問題是,它凍結在第一p = sess.run(model2layers(example_batch))
,它停在那裏無限期。
示例程序有什麼問題?
如果我倒我收到以下錯誤'FailedPreconditionError(見上回溯)的順序:嘗試使用未初始化值密/ kernel' – RdlP