Created
February 26, 2018 07:51
-
-
Save gangliao/244a004854cb9e41003da85d3e9db710 to your computer and use it in GitHub Desktop.
tensorflow read data from hdfs
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 | |
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