Created
November 28, 2016 16:06
-
-
Save zhiqizhiqi/6bcb1dc50facfd992639f09e9af463a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
import time | |
from datetime import datetime | |
import numpy as np | |
FLAGS = tf.app.flags.FLAGS | |
tf.app.flags.DEFINE_bool('cluster', False, '') | |
def log(obj): | |
print datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3], obj | |
def main(_): | |
server = tf.train.Server.create_local_server() | |
raw_shape = [576, 3, 220, 220] | |
shape = tf.TensorShape(raw_shape) | |
if FLAGS.cluster: | |
sess = tf.Session(server.target) | |
else: | |
sess = tf.Session() | |
with tf.device('/cpu:0'): | |
q = tf.FIFOQueue(10, tf.float32, shape, name = 'Q', shared_name = 'share_queue') | |
rand_data = tf.zeros(shape) | |
init_op = tf.initialize_local_variables() | |
sess.run(init_op) | |
result = q.dequeue() | |
x = tf.placeholder(tf.float32, shape, 'data') | |
enqueue_op = q.enqueue(x) | |
while True: | |
time.sleep(1) | |
log('pushing') | |
sess.run(enqueue_op, feed_dict = {x: np.zeros(raw_shape)}) | |
log('push done') | |
sess.run(result) | |
log('pop done') | |
if __name__ == '__main__': | |
tf.logging.set_verbosity(tf.logging.INFO) | |
tf.app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment