Skip to content

Instantly share code, notes, and snippets.

@gangliao
Created February 26, 2018 07:51
Show Gist options
  • Save gangliao/244a004854cb9e41003da85d3e9db710 to your computer and use it in GitHub Desktop.
Save gangliao/244a004854cb9e41003da85d3e9db710 to your computer and use it in GitHub Desktop.
tensorflow read data from hdfs
import tensorflow as tf
filename_queue = tf.train.string_input_producer(["hdfs://10.152.104.73:8020/sogou/train-data/1_final.feature_transform"])
reader = tf.WholeFileReader()
key, value = reader.read(filename_queue)
with tf.Session() as sess:
# Start populating the filename queue.
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
id, val = sess.run([key, value])
for v in val.splitlines():
print(v.decode())
coord.request_stop()
coord.join(threads)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment