我有一个TensorFlow集群启动并运行,我正在尝试使用一个客户端进程将数据入队,并将其从另一个进程出列.我不能让这个工作,我做错了什么?
这是推送数据的程序:
# queue_push.py
import tensorflow as tf
import time
with tf.container("qtest"):
q = tf.FIFOQueue(capacity=10, dtypes=[tf.float32],
shapes=[[]], name="q")
v = tf.placeholder(tf.float32, shape=())
enqueue = q.enqueue([v])
with tf.Session("grpc://localhost:2210") as sess:
while True:
t = time.time()
print(t)
sess.run(enqueue, feed_dict={v: t})
time.sleep(1)
Run Code Online (Sandbox Code Playgroud)
我的程序来拉数据:
# queue_pull.py
import tensorflow as tf
import time
with tf.container("qtest"):
q = tf.FIFOQueue(capacity=10, dtypes=[tf.float32],
shapes=[[]], name="q")
dequeue = q.dequeue()
with tf.Session("grpc://localhost:2222") as sess:
while True:
v = sess.run(dequeue)
print("Pulled:", v)
time.sleep(0.5)
Run Code Online (Sandbox Code Playgroud)
当我运行它们时,这就是我得到的:
$ python queue_push.py
1472420887.974484
1472420888.991067
1472420889.995756
1472420890.998365
1472420892.001799 …Run Code Online (Sandbox Code Playgroud)