Last active
August 22, 2018 05:24
-
-
Save ysyun/c203888b0df091157fb045f4c553c653 to your computer and use it in GitHub Desktop.
Loading data in tensorflow
This file contains 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
/* | |
$ cat test.csv | |
1,2,3,,5,6,7,8,9 | |
0,9,8,7,6,5,4,3,2 | |
2,3,4,5,6,7,8,9,0 | |
5,4,3,2,16,7,8,9,3 | |
*/ | |
import tensorflow as tf | |
filename_queue = tf.train.string_input_producer(['./test.csv']) | |
reader = tf.TextLineReader() | |
key, value = reader.read(filename_queue) | |
record_defaults = [[1], [1], [1], [1], [1], [1], [1], [1], [1]] | |
col1, col2, col3, col4, col5, col6, col7, col8, col9 = tf.decode_csv(value, record_defaults=record_defaults) | |
features = tf.stack([col1, col2, col3, col4, col5, col6, col7, col8, col9]) | |
with tf.Session() as sess: | |
coord = tf.train.Coordinator() | |
threads = tf.train.start_queue_runners(coord=coord) | |
for i in range(5): | |
example, label = sess.run([features, col9]) | |
print('example:', example, 'label:', label) | |
coord.request_stop() | |
coord.join(threads) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment