0

I attempted to use tf.TextLineReader to read text dataset, but olny odd-numbered line was read in. I don't know why. How should i do to make it read data line by line?

import tensorflow as tf
filename_queue=tf.train.string_input_producer(["./data/all_c_dev.en"])

reader=tf.TextLineReader()
key,value=reader.read(filename_queue)


with tf.Session() as sess:
    tf.train.start_queue_runners()
    for i in range(10):
        print(key.eval(),value.eval())

running result

nomadlx
  • 155
  • 2
  • 10

1 Answers1

0

When you call key.eval(), you're updating both key and value. Then, when you call value.eval(), you're updating key and value again.

You can fix this by updating both variables in a single call to sess.run:

with tf.Session() as sess:
    tf.train.start_queue_runners()
    for i in range(10):
        k, v = sess.run([key, value])
        print(k,v)
MatthewScarpino
  • 5,672
  • 5
  • 33
  • 47